From 7e6787ff383aa0e1257bb0df70d7695ec9ab04d5 Mon Sep 17 00:00:00 2001 From: cnst Date: Tue, 30 Jul 2024 21:41:28 +0200 Subject: [PATCH] completely ripping off fufexan in hopes of fixing things --- flake.lock | 275 +++++++++++++------ flake.nix | 115 ++++---- home/cnst.nix | 36 +++ home/users/cnst/{imports.nix => default.nix} | 0 home/users/cnst/home.nix | 36 --- home/users/default.nix | 49 ++++ nixos/core/lanzaboote.nix | 24 ++ nixos/default.nix | 28 ++ nixos/extra/gamemode/default.nix | 11 +- nixos/hardware/cnix.nix | 2 +- nixos/hosts/cnix/default.nix | 39 +-- nixos/hosts/cnix/hardware-configuration.nix | 33 +-- nixos/hosts/cnix/system.nix | 31 ++- nixos/hosts/default.nix | 74 +++++ nixos/pkgs/default.nix | 13 + nixos/pkgs/wl-ocr/default.nix | 17 ++ pre-commit-hooks.nix | 15 + 17 files changed, 549 insertions(+), 249 deletions(-) create mode 100644 home/cnst.nix rename home/users/cnst/{imports.nix => default.nix} (100%) delete mode 100644 home/users/cnst/home.nix create mode 100644 home/users/default.nix create mode 100644 nixos/core/lanzaboote.nix create mode 100644 nixos/default.nix create mode 100644 nixos/hosts/default.nix create mode 100644 nixos/pkgs/default.nix create mode 100644 nixos/pkgs/wl-ocr/default.nix create mode 100644 pre-commit-hooks.nix diff --git a/flake.lock b/flake.lock index ba2af0ba..c037fd21 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ ] }, "locked": { - "lastModified": 1722283490, - "narHash": "sha256-xqaO+h2ams6bpfNdUAtvWN6SKuNIeyr3lXYsAKYS/+0=", + "lastModified": 1722347739, + "narHash": "sha256-rAoh+K6KG+b1DwSWtqRVocdojnH6nGk6q07mNltoUSM=", "owner": "hyprwm", "repo": "aquamarine", - "rev": "9ccb4411ee001715db0fbc74e7ff1cea02c6c24f", + "rev": "7c3565f9bedc7cb601cc0baa14792247e4dc1d5a", "type": "github" }, "original": { @@ -94,11 +94,11 @@ ] }, "locked": { - "lastModified": 1717535930, - "narHash": "sha256-1hZ/txnbd/RmiBPNUs7i8UQw2N89uAK3UzrGAWdnFfU=", + "lastModified": 1721842668, + "narHash": "sha256-k3oiD2z2AAwBFLa4+xfU+7G5fisRXfkvrMTCJrjZzXo=", "owner": "ipetkov", "repo": "crane", - "rev": "55e7754ec31dac78980c8be45f8a28e80e370946", + "rev": "529c1a0b1f29f0d78fa3086b8f6a134c71ef3aaf", "type": "github" }, "original": { @@ -168,7 +168,6 @@ } }, "flake-compat_2": { - "flake": false, "locked": { "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", @@ -184,6 +183,22 @@ } }, "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_4": { "locked": { "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", @@ -200,16 +215,15 @@ "flake-parts": { "inputs": { "nixpkgs-lib": [ - "lanzaboote", "nixpkgs" ] }, "locked": { - "lastModified": 1717285511, - "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", "type": "github" }, "original": { @@ -219,6 +233,27 @@ } }, "flake-parts_2": { + "inputs": { + "nixpkgs-lib": [ + "lanzaboote", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "nixvim", @@ -311,25 +346,7 @@ }, "flake-utils_4": { "inputs": { - "systems": "systems_5" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_5": { - "inputs": { - "systems": "systems_7" + "systems": "systems_6" }, "locked": { "lastModified": 1710146030, @@ -436,6 +453,27 @@ "type": "github" } }, + "gitignore_3": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "hardware": { "locked": { "lastModified": 1722332872, @@ -571,11 +609,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1722347414, - "narHash": "sha256-HTj5Ttd1BjWJX/gGqyYLlwXhGjMTVKIxmi3q8s6pOTQ=", + "lastModified": 1722366828, + "narHash": "sha256-grUcMvIZs3ncEg2irrFJtTPxR0YaOYO4D1CgUB+u0dg=", "ref": "refs/heads/main", - "rev": "cc7c117fe76ff0a4da56b18026c725501de92c84", - "revCount": 5027, + "rev": "8ec3dc4c09c30aab7669f99ba6359be320023fa8", + "revCount": 5028, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" @@ -717,24 +755,22 @@ "lanzaboote": { "inputs": { "crane": "crane", - "flake-compat": "flake-compat_2", - "flake-parts": "flake-parts", - "flake-utils": "flake-utils_3", + "flake-compat": "flake-compat_3", + "flake-parts": "flake-parts_2", "nixpkgs": "nixpkgs_3", "pre-commit-hooks-nix": "pre-commit-hooks-nix", "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1718178907, - "narHash": "sha256-eSZyrQ9uoPB9iPQ8Y5H7gAmAgAvCw3InStmU3oEjqsE=", + "lastModified": 1722329086, + "narHash": "sha256-e/fSi0WER06N8WCvpht62fkGtWfe5ckDxr6zNYkwkFw=", "owner": "nix-community", "repo": "lanzaboote", - "rev": "b627ccd97d0159214cee5c7db1412b75e4be6086", + "rev": "f5a3a7dff44d131807fc1a89fbd8576cd870334a", "type": "github" }, "original": { "owner": "nix-community", - "ref": "v0.4.1", "repo": "lanzaboote", "type": "github" } @@ -812,6 +848,30 @@ "type": "github" } }, + "nix-gaming": { + "inputs": { + "flake-parts": [ + "flake-parts" + ], + "nixpkgs": [ + "nixpkgs" + ], + "umu": "umu" + }, + "locked": { + "lastModified": 1722241867, + "narHash": "sha256-//9wuNlkw5JZU2C3ELs8TtAtZE5HWVPtcM6fmgk2IUA=", + "owner": "fufexan", + "repo": "nix-gaming", + "rev": "7a07614bba2b5674b4f3b5c4d7baf80e71a55406", + "type": "github" + }, + "original": { + "owner": "fufexan", + "repo": "nix-gaming", + "type": "github" + } + }, "nix-github-actions": { "inputs": { "nixpkgs": [ @@ -868,16 +928,32 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1710695816, - "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "614b4613980a522ba49f0d194531beddbb7220d3", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.11", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } @@ -900,11 +976,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1717794163, - "narHash": "sha256-Ch6ZpFPVvi7Bb6gmmuufpTEFkXqa43pC94XMfU5FEt0=", + "lastModified": 1722264024, + "narHash": "sha256-gomyYQrlOltr2/prDRikRDQoPz+J5Qq6SEJrqVC5x2c=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "121f68ed7c6c32de5a8ce91a08ef25713d1c4755", + "rev": "fc5e08c73022f96cfeaefa2e087e8b713d47d201", "type": "github" }, "original": { @@ -949,8 +1025,8 @@ "nixvim": { "inputs": { "devshell": "devshell", - "flake-compat": "flake-compat_3", - "flake-parts": "flake-parts_2", + "flake-compat": "flake-compat_4", + "flake-parts": "flake-parts_3", "git-hooks": "git-hooks", "home-manager": "home-manager_3", "nix-darwin": "nix-darwin", @@ -976,7 +1052,7 @@ }, "nuschtosSearch": { "inputs": { - "flake-utils": "flake-utils_4", + "flake-utils": "flake-utils_3", "nixpkgs": [ "nixvim", "nixpkgs" @@ -996,6 +1072,31 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": [ + "flake-compat" + ], + "gitignore": "gitignore_3", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable_2" + }, + "locked": { + "lastModified": 1721042469, + "narHash": "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "f451c19376071a90d8c58ab1a953c6e9840527fd", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -1010,11 +1111,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1717664902, - "narHash": "sha256-7XfBuLULizXjXfBYy/VV+SpYMHreNRHk9nKMsm1bgb4=", + "lastModified": 1721042469, + "narHash": "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "cc4d466cb1254af050ff7bdf47f6d404a7c646d1", + "rev": "f451c19376071a90d8c58ab1a953c6e9840527fd", "type": "github" }, "original": { @@ -1027,34 +1128,34 @@ "inputs": { "chaotic": "chaotic", "firefox-nightly": "firefox-nightly", + "flake-compat": "flake-compat_2", + "flake-parts": "flake-parts", "flake-utils": "flake-utils_2", "hardware": "hardware", "home-manager": "home-manager_2", "hyprland": "hyprland", "lanzaboote": "lanzaboote", + "nix-gaming": "nix-gaming", "nixpkgs": "nixpkgs_4", "nixvim": "nixvim", - "systems": "systems_6", + "pre-commit-hooks": "pre-commit-hooks", + "systems": "systems_5", "wezterm": "wezterm" } }, "rust-overlay": { "inputs": { - "flake-utils": [ - "lanzaboote", - "flake-utils" - ], "nixpkgs": [ "lanzaboote", "nixpkgs" ] }, "locked": { - "lastModified": 1717813066, - "narHash": "sha256-wqbRwq3i7g5EHIui0bIi84mdqZ/It1AXBSLJ5tafD28=", + "lastModified": 1722219664, + "narHash": "sha256-xMOJ+HW4yj6e69PvieohUJ3dBSdgCfvI0nnCEe6/yVc=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "6dc3e45fe4aee36efeed24d64fc68b1f989d5465", + "rev": "a6fbda5d9a14fb5f7c69b8489d24afeb349c7bb4", "type": "github" }, "original": { @@ -1145,21 +1246,6 @@ } }, "systems_5": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_6": { "locked": { "lastModified": 1689347949, "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", @@ -1174,7 +1260,7 @@ "type": "github" } }, - "systems_7": { + "systems_6": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", @@ -1210,9 +1296,34 @@ "type": "github" } }, + "umu": { + "inputs": { + "nixpkgs": [ + "nix-gaming", + "nixpkgs" + ] + }, + "locked": { + "dir": "packaging/nix", + "lastModified": 1722028419, + "narHash": "sha256-kiujJqlhP1YUDf0+KfC+o7wdfltZUOBpJbPFPgR18hA=", + "ref": "refs/heads/main", + "rev": "7e00027c1bf9f4402318ee0530d95d34fbbc72c8", + "revCount": 684, + "submodules": true, + "type": "git", + "url": "https://github.com/Open-Wine-Components/umu-launcher/?dir=packaging/nix" + }, + "original": { + "dir": "packaging/nix", + "submodules": true, + "type": "git", + "url": "https://github.com/Open-Wine-Components/umu-launcher/?dir=packaging/nix" + } + }, "wezterm": { "inputs": { - "flake-utils": "flake-utils_5", + "flake-utils": "flake-utils_4", "freetype2": "freetype2", "harfbuzz": "harfbuzz", "libpng": "libpng", @@ -1253,11 +1364,11 @@ ] }, "locked": { - "lastModified": 1722181019, - "narHash": "sha256-Lj/g1UzrsTZUixtveQix6eB3pon2j23qv5/5pzTx0LQ=", + "lastModified": 1722365976, + "narHash": "sha256-Khdm+mDzYA//XaU0M+hftod+rKr5q9SSHSEuiQ0/9ow=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "0e2f3b9c85f7bab3983098a01366876d34daf383", + "rev": "7f2a77ddf60390248e2a3de2261d7102a13e5341", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 281b3ad6..3b75282d 100644 --- a/flake.nix +++ b/flake.nix @@ -1,17 +1,50 @@ { description = "My NixOS"; + outputs = inputs: + inputs.flake-parts.lib.mkFlake {inherit inputs;} { + systems = ["x86_64-linux"]; + + imports = [ + ./home/users + ./nixos/hosts + ./nixos/pkgs + ./pre-commit-hooks.nix + ]; + + perSystem = { + config, + pkgs, + ... + }: { + devShells.default = pkgs.mkShell { + packages = [ + pkgs.alejandra + pkgs.git + pkgs.nodePackages.prettier + ]; + name = "dots"; + DIRENV_LOG_FORMAT = ""; + shellHook = '' + ${config.pre-commit.installationScript} + ''; + }; + + formatter = pkgs.alejandra; + }; + }; inputs = { # Nix environs nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05"; systems.url = "github:nix-systems/default-linux"; hardware.url = "github:nixos/nixos-hardware"; - lanzaboote.url = "github:nix-community/lanzaboote/v0.4.1"; + lanzaboote.url = "github:nix-community/lanzaboote"; flake-utils = { url = "github:numtide/flake-utils"; inputs.systems.follows = "systems"; }; + flake-compat.url = "github:edolstra/flake-compat"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -20,83 +53,29 @@ url = "github:nix-community/nixvim"; inputs.nixpkgs.follows = "nixpkgs"; }; + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; # cachyos chaotic.url = "https://flakehub.com/f/chaotic-cx/nyx/*.tar.gz"; hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1"; - #nix-gl = { - # url = "github:nix-community/nixgl"; - # inputs.nixpkgs.follows = "nixpkgs"; - #}; - # anyrun.url = "github:anyrun-org/anyrun"; - # Neovim Nightly - #neovim-nightly-overlay = { - # url = "github:nix-community/neovim-nightly-overlay"; - # inputs.nixpkgs.follows = "nixpkgs"; - #}; - # Firefox Nightly + nix-gaming = { + url = "github:fufexan/nix-gaming"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-parts.follows = "flake-parts"; + }; firefox-nightly = { url = "github:nix-community/flake-firefox-nightly"; inputs.nixpkgs.follows = "nixpkgs"; }; - #fenix = { - # url = "github:nix-community/fenix"; - # inputs.nixpkgs.follows = "nixpkgs"; - #}; - # ags.url = "github:Aylur/ags"; wezterm = { url = "github:wez/wezterm?dir=nix"; }; - }; - outputs = { - self, - nixpkgs, - home-manager, - systems, - lanzaboote, - flake-utils, - ... - } @ inputs: let - inherit (self) outputs; - lib = nixpkgs.lib // home-manager.lib; - forEachSystem = f: lib.genAttrs (import systems) (system: f pkgsFor.${system}); - pkgsFor = lib.genAttrs (import systems) ( - system: - import nixpkgs { - inherit system; - config.allowUnfree = true; - } - ); - in { - inherit lib; - devShells = forEachSystem (pkgs: import ./nixos/core/shells/dev.nix {inherit pkgs;}); - formatter = forEachSystem (pkgs: pkgs.alejandra); - - nixosConfigurations = { - cnix = lib.nixosSystem { - modules = [ - ./nixos/hosts/cnix - lanzaboote.nixosModules.lanzaboote - inputs.chaotic.nixosModules.default - ]; - specialArgs = { - inherit inputs outputs; - }; - }; - adampad = lib.nixosSystem { - modules = [./nixos/hosts/adampad]; - specialArgs = { - inherit inputs outputs; - }; - }; - toothpc = lib.nixosSystem { - modules = [ - ./nixos/hosts/toothpc - lanzaboote.nixosModules.lanzaboote - ]; - specialArgs = { - inherit inputs outputs; - }; - }; + pre-commit-hooks = { + url = "github:cachix/pre-commit-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-compat.follows = "flake-compat"; }; }; } diff --git a/home/cnst.nix b/home/cnst.nix new file mode 100644 index 00000000..2aac2224 --- /dev/null +++ b/home/cnst.nix @@ -0,0 +1,36 @@ +{ + lib, + self, + inputs, + ... +}: { + imports = [ + # inputs.matugen.nixosModules.default + # inputs.nix-index-db.hmModules.nix-index + # inputs.tailray.homeManagerModules.default + # self.nixosModules.theme + ]; + + home = { + username = "cnst"; + homeDirectory = "/home/cnst"; + stateVersion = "23.11"; + extraOutputsToInstall = ["doc" "devdoc"]; + }; + + # disable manuals as nmd fails to build often + manual = { + html.enable = false; + json.enable = false; + manpages.enable = false; + }; + + # let HM manage itself when in standalone mode + programs.home-manager.enable = true; + + nixpkgs.overlays = [ + (final: prev: { + lib = prev.lib // {colors = import "${self}/lib/colors" lib;}; + }) + ]; +} diff --git a/home/users/cnst/imports.nix b/home/users/cnst/default.nix similarity index 100% rename from home/users/cnst/imports.nix rename to home/users/cnst/default.nix diff --git a/home/users/cnst/home.nix b/home/users/cnst/home.nix deleted file mode 100644 index 7dffa8fb..00000000 --- a/home/users/cnst/home.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - inputs, - lib, - config, - pkgs, - ... -}: { - imports = [ - ./imports.nix - ]; - - nix = { - package = lib.mkDefault pkgs.nix; - settings = { - experimental-features = [ - "nix-command" - "flakes" - ]; - warn-dirty = false; - }; - }; - - # TODO: Set your username - home = { - username = "cnst"; - homeDirectory = "/home/cnst"; - }; - - programs.home-manager.enable = true; - - # Nicely reload system units when changing configs - systemd.user.startServices = "sd-switch"; - - # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - home.stateVersion = "23.11"; -} diff --git a/home/users/default.nix b/home/users/default.nix new file mode 100644 index 00000000..e08253dd --- /dev/null +++ b/home/users/default.nix @@ -0,0 +1,49 @@ +{ + self, + inputs, + ... +}: let + # get these into the module system + extraSpecialArgs = {inherit inputs self;}; + + homeImports = { + "cnst@cnix" = [ + ../cnst.nix + ./cnst + ]; + "adam@adampad" = [ + ../adam.nix + ./adam + ]; + "toothpick@toothpc" = [ + ../toothpick.nix + ./toothpick + ]; + }; + + inherit (inputs.hm.lib) homeManagerConfiguration; + + pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; +in { + # we need to pass this to NixOS' HM module + _module.args = {inherit homeImports;}; + + flake = { + homeConfigurations = { + "cnst_cnix" = homeManagerConfiguration { + modules = homeImports."cnst@cnix"; + inherit pkgs extraSpecialArgs; + }; + + "adam_adampad" = homeManagerConfiguration { + modules = homeImports."adam@adampad"; + inherit pkgs extraSpecialArgs; + }; + + "toothpick_toothpc" = homeManagerConfiguration { + modules = homeImports."toothpick@toothpc"; + inherit pkgs extraSpecialArgs; + }; + }; + }; +} diff --git a/nixos/core/lanzaboote.nix b/nixos/core/lanzaboote.nix new file mode 100644 index 00000000..7f074e81 --- /dev/null +++ b/nixos/core/lanzaboote.nix @@ -0,0 +1,24 @@ +{ + pkgs, + lib, + inputs, + ... +}: +# lanzaboote config +{ + imports = [ + inputs.lanzaboote.nixosModules.lanzaboote + ]; + + boot = { + lanzaboote = { + enable = true; + pkiBundle = "/etc/secureboot"; + }; + + # we let lanzaboote install systemd-boot + loader.systemd-boot.enable = lib.mkForce false; + }; + + environment.systemPackages = [pkgs.sbctl]; +} diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 00000000..e649cc76 --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1,28 @@ +let + desktop = [ + ./core/hyprland.nix + ./core/zsh.nix + ./core/fonts.nix + + ./locale + + ./services/audio + ./services/greetd + ./services/gnome-keyring + ./services/gvfs + ./services/locate + ./services/mullvad + ./services/openssh + ./services/power + ./services/samba + ./services/udisks + ]; + + laptop = + desktop + ++ [ + ./services/fwupd + ]; +in { + inherit desktop laptop; +} diff --git a/nixos/extra/gamemode/default.nix b/nixos/extra/gamemode/default.nix index 8d7e06c6..b72f6696 100644 --- a/nixos/extra/gamemode/default.nix +++ b/nixos/extra/gamemode/default.nix @@ -1,4 +1,8 @@ -{pkgs, ...}: { +{ + pkgs, + inputs, + ... +}: { programs.gamemode = { enable = true; settings = { @@ -17,4 +21,9 @@ }; }; }; + # see https://github.com/fufexan/nix-gaming/#pipewire-low-latency + services.pipewire.lowLatency.enable = true; + imports = [ + inputs.nix-gaming.nixosModules.pipewireLowLatency + ]; } diff --git a/nixos/hardware/cnix.nix b/nixos/hardware/cnix.nix index 38b0e547..fbba64eb 100644 --- a/nixos/hardware/cnix.nix +++ b/nixos/hardware/cnix.nix @@ -4,7 +4,7 @@ hardware = { bluetooth = { enable = true; - powerOnBoot = true; + powerOnBoot = false; }; logitech.wireless = { enable = true; diff --git a/nixos/hosts/cnix/default.nix b/nixos/hosts/cnix/default.nix index 99cec7be..96d92aa6 100644 --- a/nixos/hosts/cnix/default.nix +++ b/nixos/hosts/cnix/default.nix @@ -37,44 +37,19 @@ in { imports = [ inputs.home-manager.nixosModules.home-manager - ./imports.nix ./system.nix ./hardware-configuration.nix ./substituters.nix ]; - home-manager.users.cnst = import ../../../home/users/cnst/home.nix; + boot.kernelPackages = lib.mkForce pkgs.linuxPackages_cachyos; + environment.systemPackages = [pkgs.scx]; - nix = { - # pin the registry to avoid downloading and evaling a new nixpkgs version every time - registry = lib.mapAttrs (_: v: {flake = v;}) inputs; - - # set the path for channels compat - nixPath = lib.mapAttrsToList (key: _: "${key}=flake:${key}") config.nix.registry; - - settings = { - auto-optimise-store = true; - builders-use-substitutes = true; - warn-dirty = false; - experimental-features = ["nix-command" "flakes"]; - flake-registry = "/etc/nix/registry.json"; - - # for direnv GC roots - keep-derivations = true; - keep-outputs = true; - - trusted-users = ["root" "@wheel"]; - }; - }; - # Bootloader - boot.loader = { - systemd-boot.enable = lib.mkForce false; - efi.canTouchEfiVariables = true; - }; - boot.lanzaboote = { - enable = true; - pkiBundle = "/etc/secureboot"; - }; + boot.kernelParams = [ + "amd_pstate=active" + "quiet" + "splash" + ]; environment.sessionVariables = { FLAKE = "/home/cnst/.nix-config"; diff --git a/nixos/hosts/cnix/hardware-configuration.nix b/nixos/hosts/cnix/hardware-configuration.nix index 08632989..eddf0358 100644 --- a/nixos/hosts/cnix/hardware-configuration.nix +++ b/nixos/hosts/cnix/hardware-configuration.nix @@ -9,28 +9,17 @@ ... }: { imports = [(modulesPath + "/installer/scan/not-detected.nix")]; - boot = { - initrd = { - availableKernelModules = [ - "nvme" - "xhci_pci" - "ahci" - "usbhid" - "usb_storage" - "sd_mod" - ]; - kernelModules = ["amdgpu"]; - }; - kernelModules = ["kvm-amd"]; - kernelPackages = lib.mkForce pkgs.linuxPackages_cachyos; - consoleLogLevel = 3; - kernelParams = [ - "amd_pstate=active" - "quiet" - "splash" - ]; - extraModulePackages = []; - }; + boot.initrd.availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + ]; + boot.initrd.kernelModules = ["amdgpu"]; + boot.kernelModules = ["kvm-amd"]; + boot.extraModulePackages = []; fileSystems."/" = { device = "/dev/disk/by-uuid/de372c64-89a2-4bbe-ad57-926cdd98e97d"; diff --git a/nixos/hosts/cnix/system.nix b/nixos/hosts/cnix/system.nix index 61bf104c..849c2884 100644 --- a/nixos/hosts/cnix/system.nix +++ b/nixos/hosts/cnix/system.nix @@ -1,6 +1,8 @@ { inputs, outputs, + lib, + config, ... }: { programs = { @@ -12,6 +14,27 @@ }; }; + nix = { + # pin the registry to avoid downloading and evaling a new nixpkgs version every time + registry = lib.mapAttrs (_: v: {flake = v;}) inputs; + + # set the path for channels compat + nixPath = lib.mapAttrsToList (key: _: "${key}=flake:${key}") config.nix.registry; + + settings = { + auto-optimise-store = true; + builders-use-substitutes = true; + experimental-features = ["nix-command" "flakes"]; + flake-registry = "/etc/nix/registry.json"; + + # for direnv GC roots + keep-derivations = true; + keep-outputs = true; + + trusted-users = ["root" "@wheel"]; + }; + }; + security = { rtkit.enable = true; pam.services.hyprlock = {}; @@ -20,13 +43,7 @@ environment.localBinInPath = true; console.useXkbConfig = true; - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - extraSpecialArgs = { - inherit inputs outputs; - }; - }; + nixpkgs = { overlays = [ (_: prev: { diff --git a/nixos/hosts/default.nix b/nixos/hosts/default.nix new file mode 100644 index 00000000..77092c34 --- /dev/null +++ b/nixos/hosts/default.nix @@ -0,0 +1,74 @@ +{ + self, + inputs, + homeImports, + ... +}: { + flake.nixosConfigurations = let + # shorten paths + inherit (inputs.nixpkgs.lib) nixosSystem; + mod = "${self}/nixos"; + + # get the basic config to build on top of + inherit (import "${self}/nixos") desktop laptop; + + # get these into the module system + specialArgs = {inherit inputs self;}; + in { + cnix = nixosSystem { + inherit specialArgs; + modules = + desktop + ++ [ + ./cnix + "${mod}/core/lanzaboote.nix" + "${mod}/core/network/cnix.nix" + + "${mod}/hardware/cnix.nix" + + "${mod}/services/blueman" + "${mod}/services/xserver/cnix.nix" + + "${mod}/extra/gaming.nix" + "${mod}/extra/android" + "${mod}/extra/workstation" + { + home-manager = { + users.cnst.imports = homeImports."cnst@cnix"; + extraSpecialArgs = specialArgs; + }; + } + + # inputs.agenix.nixosModules.default + inputs.chaotic.nixosModules.default + ]; + }; + + # rog = nixosSystem { + # inherit specialArgs; + # modules = + # laptop + # ++ [ + # ./rog + # "${mod}/core/lanzaboote.nix" + + # "${mod}/programs/gamemode.nix" + # "${mod}/programs/hyprland.nix" + # "${mod}/programs/games.nix" + + # "${mod}/services/kanata" + # {home-manager.users.mihai.imports = homeImports."mihai@rog";} + # ]; + # }; + + # kiiro = nixosSystem { + # inherit specialArgs; + # modules = + # desktop + # ++ [ + # ./kiiro + # {home-manager.users.mihai.imports = homeImports.server;} + # ]; + # }; + }; +} diff --git a/nixos/pkgs/default.nix b/nixos/pkgs/default.nix new file mode 100644 index 00000000..d942dcb3 --- /dev/null +++ b/nixos/pkgs/default.nix @@ -0,0 +1,13 @@ +{ + systems = ["x86_64-linux"]; + + perSystem = { + pkgs, + inputs', + ... + }: { + packages = { + wl-ocr = pkgs.callPackage ./wl-ocr {}; + }; + }; +} diff --git a/nixos/pkgs/wl-ocr/default.nix b/nixos/pkgs/wl-ocr/default.nix new file mode 100644 index 00000000..6c3a4eba --- /dev/null +++ b/nixos/pkgs/wl-ocr/default.nix @@ -0,0 +1,17 @@ +{ + writeShellScriptBin, + lib, + grim, + libnotify, + slurp, + tesseract5, + wl-clipboard, + langs ? "eng+hun+fra+jpn+jpn_vert+kor+kor_vert+pol+ron+spa", +}: let + _ = lib.getExe; +in + writeShellScriptBin "wl-ocr" '' + ${_ grim} -g "$(${_ slurp})" -t ppm - | ${_ tesseract5} -l ${langs} - - | ${wl-clipboard}/bin/wl-copy + echo "$(${wl-clipboard}/bin/wl-paste)" + ${_ libnotify} -- "$(${wl-clipboard}/bin/wl-paste)" + '' diff --git a/pre-commit-hooks.nix b/pre-commit-hooks.nix new file mode 100644 index 00000000..fcd5653f --- /dev/null +++ b/pre-commit-hooks.nix @@ -0,0 +1,15 @@ +{inputs, ...}: { + imports = [inputs.pre-commit-hooks.flakeModule]; + + perSystem.pre-commit = { + settings.excludes = ["flake.lock"]; + + settings.hooks = { + alejandra.enable = true; + prettier = { + enable = true; + excludes = [".js" ".md" ".ts"]; + }; + }; + }; +}