diff --git a/flake.lock b/flake.lock index a99a16c..bd6c11d 100644 --- a/flake.lock +++ b/flake.lock @@ -4,10 +4,10 @@ "inputs": { "darwin": "darwin", "home-manager": [ - "home" + "home-manager" ], "nixpkgs": [ - "nixos" + "nixpkgs" ] }, "locked": { @@ -45,70 +45,10 @@ "type": "github" } }, - "beautysh": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "poetry2nix": "poetry2nix" - }, - "locked": { - "lastModified": 1641830469, - "narHash": "sha256-uhDmgNP/biOWe4FtOa6c2xZnREH+NP9rdrMm0LccRUk=", - "owner": "lovesegfault", - "repo": "beautysh", - "rev": "e85d9736927c0fcf2abb05cb3a2d8d9b4502a2eb", - "type": "github" - }, - "original": { - "owner": "lovesegfault", - "repo": "beautysh", - "type": "github" - } - }, - "blank": { - "locked": { - "lastModified": 1625557891, - "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", - "owner": "divnix", - "repo": "blank", - "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "blank", - "type": "github" - } - }, - "bud": { - "inputs": { - "beautysh": "beautysh", - "devshell": [ - "digga", - "devshell" - ], - "nixpkgs": [ - "nixos" - ] - }, - "locked": { - "lastModified": 1654190822, - "narHash": "sha256-B8z3stYaULNDBBjzJHrFHGgiJHrLqhBkxH+9u5iBP7E=", - "owner": "divnix", - "repo": "bud", - "rev": "0ff3e4e4b8791ea4d827bf5bfcac28cef060f209", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "bud", - "type": "github" - } - }, "crane": { "inputs": { - "flake-compat": "flake-compat_4", - "flake-utils": "flake-utils_8", + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_4", "nixpkgs": [ "universe-cli", "nixpkgs" @@ -153,18 +93,15 @@ }, "devshell": { "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": [ - "digga", - "nixpkgs" - ] + "nixpkgs": "nixpkgs", + "systems": "systems" }, "locked": { - "lastModified": 1671489820, - "narHash": "sha256-qoei5HDJ8psd1YUPD7DhbHdhLIT9L2nadscp4Qk37uk=", + "lastModified": 1688380630, + "narHash": "sha256-8ilApWVb1mAi4439zS3iFeIT0ODlbrifm/fegWwgHjA=", "owner": "numtide", "repo": "devshell", - "rev": "5aa3a8039c68b4bf869327446590f4cdf90bb634", + "rev": "f9238ec3d75cefbb2b42a44948c4e8fb1ae9a205", "type": "github" }, "original": { @@ -195,46 +132,9 @@ "type": "github" } }, - "digga": { - "inputs": { - "darwin": [ - "blank" - ], - "deploy": [ - "blank" - ], - "devshell": "devshell", - "flake-compat": "flake-compat", - "flake-utils": "flake-utils_3", - "flake-utils-plus": "flake-utils-plus", - "home-manager": [ - "home" - ], - "nixlib": [ - "nixos" - ], - "nixpkgs": [ - "nixos" - ], - "nixpkgs-unstable": "nixpkgs-unstable" - }, - "locked": { - "lastModified": 1674665318, - "narHash": "sha256-k3soI+AnNz+9WRU64qv23arssUjnYSwXdJXsPEiFu9I=", - "owner": "divnix", - "repo": "digga", - "rev": "0595ae70cdb5ccf1ab031199fe98551c4b378bd9", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "digga", - "type": "github" - } - }, "emacs-overlay": { "inputs": { - "flake-utils": "flake-utils_5", + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs_2" }, "locked": { @@ -254,7 +154,7 @@ "fenix": { "inputs": { "nixpkgs": [ - "nixos" + "nixpkgs" ], "rust-analyzer-src": "rust-analyzer-src" }, @@ -275,11 +175,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1668681692, - "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "owner": "edolstra", "repo": "flake-compat", - "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "type": "github" }, "original": { @@ -320,23 +220,27 @@ "type": "github" } }, - "flake-compat_4": { - "flake": false, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "lastModified": 1688466019, + "narHash": "sha256-VeM2akYrBYMsb4W/MmBo1zmaMfgbL4cH3Pu8PGyIwJ0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "8e8d955c22df93dbe24f19ea04f47a74adbdc5ec", "type": "github" }, "original": { - "owner": "edolstra", - "repo": "flake-compat", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, - "flake-parts": { + "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "universe-cli", @@ -358,88 +262,6 @@ } }, "flake-utils": { - "locked": { - "lastModified": 1631561581, - "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils-plus": { - "inputs": { - "flake-utils": "flake-utils_4" - }, - "locked": { - "lastModified": 1683999906, - "narHash": "sha256-LZprVmOTM+3iykh248bajobX9ludnMC/Ai5rOqimtFc=", - "owner": "ravensiris", - "repo": "flake-utils-plus", - "rev": "7a8d789d4d13e45d20e6826d7b2a1757d52f2e13", - "type": "github" - }, - "original": { - "owner": "gytis-ivaskevicius", - "ref": "refs/pull/120/head", - "repo": "flake-utils-plus", - "type": "github" - } - }, - "flake-utils_2": { - "locked": { - "lastModified": 1642700792, - "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_3": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_4": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_5": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -454,7 +276,7 @@ "type": "github" } }, - "flake-utils_6": { + "flake-utils_2": { "inputs": { "systems": "systems_2" }, @@ -472,7 +294,7 @@ "type": "github" } }, - "flake-utils_7": { + "flake-utils_3": { "inputs": { "systems": "systems_3" }, @@ -490,7 +312,7 @@ "type": "github" } }, - "flake-utils_8": { + "flake-utils_4": { "inputs": { "systems": "systems_4" }, @@ -508,7 +330,7 @@ "type": "github" } }, - "flake-utils_9": { + "flake-utils_5": { "inputs": { "systems": "systems_6" }, @@ -558,6 +380,27 @@ "type": "github" } }, + "haumea": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1685133229, + "narHash": "sha256-FePm/Gi9PBSNwiDFq3N+DWdfxFq0UKsVVTJS3cQPn94=", + "owner": "nix-community", + "repo": "haumea", + "rev": "34dd58385092a23018748b50f9b23de6266dffc2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "v0.2.2", + "repo": "haumea", + "type": "github" + } + }, "hlissner-dotfiles": { "inputs": { "agenix": "agenix_2", @@ -565,7 +408,7 @@ "home-manager": "home-manager", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs_3", - "nixpkgs-unstable": "nixpkgs-unstable_2" + "nixpkgs-unstable": "nixpkgs-unstable" }, "locked": { "lastModified": 1663596637, @@ -581,26 +424,6 @@ "type": "github" } }, - "home": { - "inputs": { - "nixpkgs": [ - "nixos" - ] - }, - "locked": { - "lastModified": 1690027126, - "narHash": "sha256-DeUhQQxbu41Qn0uHyNazPBiTJ0lNsf26ThFopWBRRnM=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "76dd6c66190db0d46ac6b3ca816cc17b581df42c", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "home-manager", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -624,6 +447,26 @@ "type": "github" } }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1690476848, + "narHash": "sha256-PSmzyuEbMxEn2uwwLYUN2l1psoJXb7jm/kfHD12Sq0k=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "8d243f7da13d6ee32f722a3f1afeced150b6d4da", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "impermanence": { "locked": { "lastModified": 1684264534, @@ -641,11 +484,11 @@ }, "latest": { "locked": { - "lastModified": 1690052557, - "narHash": "sha256-dkqqefnFa5iQWckSNLtumYdtk0Sn7wQfbUcCAl6TJzo=", + "lastModified": 1690569970, + "narHash": "sha256-Lf1LLHyi+hajpj3dJqjMRgLMU2Fr++JEOdJyhBaxaWQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2b616df6e4817c46160ae745f3b33f97e6b5ffec", + "rev": "66ce081fafa2dca0038006ec7c6482d7a11d13d8", "type": "github" }, "original": { @@ -656,10 +499,10 @@ }, "nix-minecraft": { "inputs": { - "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_6", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", "nixpkgs": [ - "nixos" + "nixpkgs" ] }, "locked": { @@ -677,22 +520,6 @@ "type": "github" } }, - "nixos": { - "locked": { - "lastModified": 1690031011, - "narHash": "sha256-kzK0P4Smt7CL53YCdZCBbt9uBFFhE0iNvCki20etAf4=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "12303c652b881435065a98729eb7278313041e49", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nixos-hardware": { "locked": { "lastModified": 1663229557, @@ -725,8 +552,8 @@ }, "nixos-wsl": { "inputs": { - "flake-compat": "flake-compat_3", - "flake-utils": "flake-utils_7", + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_3", "nixpkgs": "nixpkgs_4" }, "locked": { @@ -745,33 +572,21 @@ }, "nixpkgs": { "locked": { - "lastModified": 0, - "narHash": "sha256-GGMupfk/lGzPBQ/dRrcQEhiFZ0F5KPg0j5Q4Fb5coxc=", - "path": "/nix/store/r2bbhmlfvfpir9hp8fjs31kj13kwgwyl-source", - "type": "path" + "lastModified": 1677383253, + "narHash": "sha256-UfpzWfSxkfXHnb4boXZNaKsAcUrZT9Hw+tao1oZxd08=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9952d6bc395f5841262b006fbace8dd7e143b634", + "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" } }, "nixpkgs-unstable": { - "locked": { - "lastModified": 1672791794, - "narHash": "sha256-mqGPpGmwap0Wfsf3o2b6qHJW1w2kk/I6cGCGIU+3t6o=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "9813adc7f7c0edd738c6bdd8431439688bb0cb3d", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-unstable_2": { "locked": { "lastModified": 1663264531, "narHash": "sha256-2ncO5chPXlTxaebDlhx7MhL0gOEIWxzSyfsl0r0hxQk=", @@ -829,30 +644,19 @@ "type": "github" } }, - "poetry2nix": { - "inputs": { - "flake-utils": [ - "bud", - "beautysh", - "flake-utils" - ], - "nixpkgs": [ - "bud", - "beautysh", - "nixpkgs" - ] - }, + "nixpkgs_5": { "locked": { - "lastModified": 1633382856, - "narHash": "sha256-hYlet806M9xJj4yxf0g5fhDT2IEUVIMAl7sqIeZ8DUM=", - "owner": "nix-community", - "repo": "poetry2nix", - "rev": "705cbfa10e3d9bfed2e59e0256844ae3704dbd7e", + "lastModified": 1690367991, + "narHash": "sha256-2VwOn1l8y6+cu7zjNE8MgeGJNNz1eat1HwHrINeogFA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c9cf0708f00fbe553319258e48ca89ff9a413703", "type": "github" }, "original": { - "owner": "nix-community", - "repo": "poetry2nix", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", "type": "github" } }, @@ -892,23 +696,21 @@ "root": { "inputs": { "agenix": "agenix", - "blank": "blank", - "bud": "bud", - "digga": "digga", + "devshell": "devshell", "fenix": "fenix", + "flake-parts": "flake-parts", "fork": "fork", + "haumea": "haumea", "hlissner-dotfiles": "hlissner-dotfiles", - "home": "home", + "home-manager": "home-manager_2", "impermanence": "impermanence", "latest": "latest", "nix-minecraft": "nix-minecraft", - "nixos": "nixos", "nixos-hardware": "nixos-hardware_2", "nixos-wsl": "nixos-wsl", + "nixpkgs": "nixpkgs_5", "private": "private", "quick-nix-registry": "quick-nix-registry", - "stable": "stable", - "staging": "staging", "universe-cli": "universe-cli" } }, @@ -958,7 +760,7 @@ }, "rust-overlay_2": { "inputs": { - "flake-utils": "flake-utils_9", + "flake-utils": "flake-utils_5", "nixpkgs": [ "universe-cli", "nixpkgs" @@ -978,38 +780,6 @@ "type": "github" } }, - "stable": { - "locked": { - "lastModified": 1689956312, - "narHash": "sha256-NV9yamMhE5jgz+ZSM2IgXeYqOvmGIbIIJ+AFIhfD7Ek=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "6da4bc6cb07cba1b8e53d139cbf1d2fb8061d967", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "staging": { - "locked": { - "lastModified": 1690050217, - "narHash": "sha256-TI+CWCORCtUgDuXvioOuoLio1JIq5eLGp133OVy3VuQ=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "cd7605a2b687970dcaf6df1eb2f667bfb68dc8ac", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "staging", - "repo": "nixpkgs", - "type": "github" - } - }, "systems": { "locked": { "lastModified": 1681028828, @@ -1104,9 +874,9 @@ "inputs": { "crane": "crane", "devshell": "devshell_2", - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "nixpkgs": [ - "nixos" + "nixpkgs" ], "rust-overlay": "rust-overlay_2" }, diff --git a/flake.nix b/flake.nix index d233890..e959070 100644 --- a/flake.nix +++ b/flake.nix @@ -2,39 +2,32 @@ description = "Infinidoge's NixOS configuration"; inputs = { + # nixpkgs + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + latest.url = "github:nixos/nixpkgs"; + fork.url = "github:Infinidoge/nixpkgs/combined/all"; + + # configuration components private.url = "git+ssh://git@github.com/Infinidoge/universe-private"; universe-cli.url = "github:Infinidoge/universe-cli"; - universe-cli.inputs.nixpkgs.follows = "nixos"; + universe-cli.inputs.nixpkgs.follows = "nixpkgs"; - # --- DevOS Flake Inputs - # # --- Channels --- - stable.url = "github:nixos/nixpkgs/nixos-23.05"; - nixos.url = "github:nixos/nixpkgs/nixos-unstable"; - latest.url = "github:nixos/nixpkgs"; - staging.url = "github:nixos/nixpkgs/staging"; - fork.url = "github:Infinidoge/nixpkgs/combined/all"; + # nix libraries + flake-parts.url = "github:hercules-ci/flake-parts"; + flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; - # # --- Libraries --- - digga.url = "github:divnix/digga"; - digga.inputs.nixpkgs.follows = "nixos"; - digga.inputs.nixlib.follows = "nixos"; - digga.inputs.home-manager.follows = "home"; - digga.inputs.deploy.follows = "blank"; - digga.inputs.darwin.follows = "blank"; - blank.url = "github:divnix/blank"; - digga.inputs.flake-utils-plus.url = "github:ravensiris/flake-utils-plus/ravensiris/fix-devshell-legacy-packages"; + haumea.url = "github:nix-community/haumea/v0.2.2"; + haumea.inputs.nixpkgs.follows = "nixpkgs"; - bud.url = "github:divnix/bud"; - bud.inputs.nixpkgs.follows = "nixos"; - bud.inputs.devshell.follows = "digga/devshell"; - - home.url = "github:nix-community/home-manager"; - home.inputs.nixpkgs.follows = "nixos"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; agenix.url = "github:ryantm/agenix"; - agenix.inputs.nixpkgs.follows = "nixos"; - agenix.inputs.home-manager.follows = "home"; + agenix.inputs.nixpkgs.follows = "nixpkgs"; + agenix.inputs.home-manager.follows = "home-manager"; + + devshell.url = "github:numtide/devshell"; nixos-hardware.url = "github:nixos/nixos-hardware"; @@ -49,132 +42,132 @@ # --- Domain-Specific Flake Inputs # # --- Minecraft nix-minecraft.url = "github:Infinidoge/nix-minecraft/develop"; - nix-minecraft.inputs.nixpkgs.follows = "nixos"; + nix-minecraft.inputs.nixpkgs.follows = "nixpkgs"; # # --- Rust fenix.url = "github:nix-community/fenix"; - fenix.inputs.nixpkgs.follows = "nixos"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = - { self - , digga - , nixos - , home - , agenix - , private - , ... - }@inputs: - digga.lib.mkFlake - { - inherit self inputs; + outputs = inputs@{ flake-parts, nixpkgs, private, ... }: flake-parts.lib.mkFlake { inherit inputs; } ({ self, lib, ... }: { + systems = [ "x86_64-linux" ]; - channelsConfig = { allowUnfree = true; }; + debug = true; - channels = { - nixos = { - imports = [ (digga.lib.importOverlays ./overlays) ]; - overlays = [ - # --- DevOS Overlays - agenix.overlays.default - ./pkgs/default.nix + perSystem = { pkgs, system, ... }: { + _module.args.pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + }; - # --- Domain-Specific Overlays - inputs.nix-minecraft.overlay - inputs.fenix.overlays.default - inputs.universe-cli.overlays.default - ]; - }; - stable = { }; - latest = { }; - staging = { }; - fork = { }; - }; + flake = { + lib = import ./lib { inherit (nixpkgs) lib; }; - lib = import ./lib { lib = digga.lib // nixos.lib; }; + users = self.lib.rakeLeaves ./users; - sharedOverlays = [ - (final: prev: { - __dontExport = true; - lib = prev.lib.extend (lfinal: lprev: { - our = self.lib; - hlissner = inputs.hlissner-dotfiles.lib; - hm = home.lib.hm; - }); - }) - ]; + nixosProfiles = self.lib.rakeLeaves ./profiles; - nixos = { - hostDefaults = { - system = "x86_64-linux"; - channelName = "nixos"; - imports = [ (digga.lib.importExportableModules ./modules) ]; - modules = let users = digga.lib.rakeLeaves ./users; in [ - # --- DevOS Modules --- - { lib.our = self.lib; } - digga.nixosModules.bootstrapIso - digga.nixosModules.nixConfig - home.nixosModules.home-manager - agenix.nixosModules.age + overlays = { + overrides = import ./overlays/overrides.nix inputs; + patches = import ./overlays/patches; + }; + + nixosConfigurations = + let + libOverlay = (lfinal: lprev: { + our = self.lib; + hlissner = inputs.hlissner-dotfiles.lib; + hm = inputs.home-manager.lib.hm; + }); + in + lib.mapAttrs + (self.lib.mkHost { + specialArgs = { + profiles = self.nixosProfiles; + lib = nixpkgs.lib.extend libOverlay; + inherit private self inputs; + }; + + modules = [ + self.users.root + self.users.infinidoge + { + nixpkgs.hostPlatform = "x86_64-linux"; + system.configurationRevision = lib.mkIf (self ? rev) self.rev; + nixpkgs.overlays = [ + (final: prev: { + lib = prev.lib.extend libOverlay; + }) + self.overlays.packages + self.overlays.patches + self.overlays.overrides + + inputs.agenix.overlays.default + + # --- Domain-Specific Overlays + inputs.nix-minecraft.overlay + inputs.fenix.overlays.default + inputs.universe-cli.overlays.default + ]; + home-manager = + let + profiles = self.lib.rakeLeaves ./users/profiles; + in + { + useUserPackages = true; + useGlobalPkgs = true; + + sharedModules = [ + inputs.impermanence.nixosModules.home-manager.impermanence + ] ++ (with profiles; [ + # Base Configuration + xdg + + # Programs + direnv + git + emacs + vim + gpg + ssh + keychain + + # Terminal + starship + shells.all + tmux + + ]) ++ (self.lib.leaves ./users/modules); + + extraSpecialArgs = { + inherit profiles; + }; + }; + } + + # --- Universe Modules --- ./secrets - private.nixosModules.networking # --- Library Modules --- inputs.nixos-wsl.nixosModules.wsl inputs.impermanence.nixosModules.impermanence inputs.quick-nix-registry.nixosModules.local-registry + inputs.home-manager.nixosModules.home-manager + inputs.agenix.nixosModules.age # --- Domain-Specific Modules --- inputs.nix-minecraft.nixosModules.minecraft-servers + ] ++ (self.lib.leaves ./modules); + }) + (self.lib.flattenLeaves ./hosts); + }; - # --- Users --- - users.root - users.infinidoge - ]; - }; - - imports = [ (digga.lib.importHosts ./hosts) ]; - importables = { - inherit private; - profiles = digga.lib.rakeLeaves ./profiles; - }; - }; - - home = - let - profiles = digga.lib.rakeLeaves ./users/profiles; - in - { - imports = [ (digga.lib.importExportableModules ./users/modules) ]; - modules = with profiles; [ - inputs.impermanence.nixosModules.home-manager.impermanence - - # Base Configuration - xdg - - # Programs - direnv - git - emacs - vim - gpg - ssh - keychain - - # Terminal - starship - shells.all - tmux - ]; - importables = { - inherit inputs profiles; - }; - }; - - devshell = ./shell; - - homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations; - } - ; + imports = [ + ./pkgs + ./shell + inputs.devshell.flakeModule + ]; + }); } diff --git a/lib/default.nix b/lib/default.nix index d2d3478..db0c21d 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -26,5 +26,9 @@ rec { sanitizeName = name: replaceStrings [ "." ] [ "" ] - (strings.sanitizeDerivationName (removePrefix "/" name)); -}) + (sanitizeDerivationName (removePrefix "/" name)); +} // ( + import ./digga.nix { inherit lib; } +) // ( + import ./hosts.nix { inherit lib; } +)) diff --git a/lib/digga.nix b/lib/digga.nix new file mode 100644 index 0000000..5831220 --- /dev/null +++ b/lib/digga.nix @@ -0,0 +1,128 @@ +{ lib }: +# Importers from digga: https://github.com/divnix/digga/blob/main/src/importers.nix +let + flattenTree = + /* + * + Synopsis: flattenTree _tree_ + + Flattens a _tree_ of the shape that is produced by rakeLeaves. + + Output Format: + An attrset with names in the spirit of the Reverse DNS Notation form + that fully preserve information about grouping from nesting. + + Example input: + ``` + { + a = { + b = { + c = ; + }; + }; + } + ``` + + Example output: + ``` + { + "a.b.c" = ; + } + ``` + * + */ + tree: + let + op = sum: path: val: + let + pathStr = builtins.concatStringsSep "." path; # dot-based reverse DNS notation + in + if builtins.isPath val + then + # builtins.trace "${toString val} is a path" + (sum + // { + "${pathStr}" = val; + }) + else if builtins.isAttrs val + then + # builtins.trace "${builtins.toJSON val} is an attrset" + # recurse into that attribute set + (recurse sum path val) + else + # ignore that value + # builtins.trace "${toString path} is something else" + sum; + + recurse = sum: path: val: + builtins.foldl' + (sum: key: op sum (path ++ [ key ]) val.${key}) + sum + (builtins.attrNames val); + in + recurse { } [ ] tree; + + rakeLeaves = + /* + * + Synopsis: rakeLeaves _path_ + + Recursively collect the nix files of _path_ into attrs. + + Output Format: + An attribute set where all `.nix` files and directories with `default.nix` in them + are mapped to keys that are either the file with .nix stripped or the folder name. + All other directories are recursed further into nested attribute sets with the same format. + + Example file structure: + ``` + ./core/default.nix + ./base.nix + ./main/dev.nix + ./main/os/default.nix + ``` + + Example output: + ``` + { + core = ./core; + base = base.nix; + main = { + dev = ./main/dev.nix; + os = ./main/os; + }; + } + ``` + * + */ + dirPath: + let + seive = file: type: + # Only rake `.nix` files or directories + (type == "regular" && lib.hasSuffix ".nix" file) || (type == "directory"); + + collect = file: type: { + name = lib.removeSuffix ".nix" file; + value = + let + path = dirPath + "/${file}"; + in + if + (type == "regular") + || (type == "directory" && builtins.pathExists (path + "/default.nix")) + then path + # recurse on directories that don't contain a `default.nix` + else rakeLeaves path; + }; + + files = lib.filterAttrs seive (builtins.readDir dirPath); + in + lib.filterAttrs (n: v: v != { }) (lib.mapAttrs' collect files); + + flattenLeaves = dir: flattenTree (rakeLeaves dir); +in +{ + inherit rakeLeaves flattenTree flattenLeaves; + + leaves = dir: builtins.attrValues (flattenLeaves dir); +} diff --git a/lib/hosts.nix b/lib/hosts.nix new file mode 100644 index 0000000..48c4cff --- /dev/null +++ b/lib/hosts.nix @@ -0,0 +1,12 @@ +{ lib }: + +{ + mkHost = attrs@{ modules ? [ ], ... }: name: path: lib.nixosSystem (attrs // { + modules = [ + { + networking.hostName = lib.mkDefault name; + } + (import path) + ] ++ attrs.modules; + }); +} diff --git a/modules/devos/nix.nix b/modules/devos/nix.nix index 2fa8c5a..114bb0c 100644 --- a/modules/devos/nix.nix +++ b/modules/devos/nix.nix @@ -24,7 +24,17 @@ with lib; optimise.automatic = true; + registry = + let + flakes = filterAttrs (n: v: v ? outputs) inputs; + in + builtins.mapAttrs (_n: v: { flake = v; }) flakes; + extraOptions = '' + extra-experimental-features = flakes nix-command + extra-substituters = https://nrdxp.cachix.org https://nix-community.cachix.org + extra-trusted-public-keys = nrdxp.cachix.org-1:Fc5PSqY2Jm1TrWfm88l6cvGWwz3s93c6IOifQWnhNW4= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= + min-free = 536870912 keep-outputs = true keep-derivations = true diff --git a/modules/global/packages.nix b/modules/global/packages.nix index 17cd13f..853787f 100644 --- a/modules/global/packages.nix +++ b/modules/global/packages.nix @@ -10,6 +10,7 @@ environment.systemPackages = with pkgs; [ universe-cli + agenix bat binutils btrfs-progs diff --git a/modules/global/security.nix b/modules/global/security.nix index 7d16711..4038cfe 100644 --- a/modules/global/security.nix +++ b/modules/global/security.nix @@ -19,6 +19,8 @@ with lib; cpu.amd.updateMicrocode = mkDefault config.hardware.enableRedistributableFirmware; }; + users.mutableUsers = false; + boot = { # Make tmp volatile, using tmpfs is speedy on SSD systems # Redundant on opt-in state systems diff --git a/overlays/overrides.nix b/overlays/overrides.nix index 9a4de85..8555a68 100644 --- a/overlays/overrides.nix +++ b/overlays/overrides.nix @@ -1,21 +1,13 @@ -channels: final: prev: { +inputs: final: prev: +let + mkPkgs = channel: channel.legacyPackages.${final.system}; - __dontExport = true; # overrides clutter up actual creations - - inherit (channels.latest) - # discord-canary - kmscon - prismlauncher + latest = mkPkgs inputs.latest; + fork = mkPkgs inputs.fork; +in +{ + inherit (latest) ; - inherit (channels.fork) - # https://nixpk.gs/pr-tracker.html?pr=244591 - firefox-devedition - ; - inherit (channels.stable) - hydrus - ; - - qtile = final.qtile-unstable; } diff --git a/pkgs/_sources/generated.json b/pkgs/_sources/generated.json deleted file mode 100644 index 377e3f4..0000000 --- a/pkgs/_sources/generated.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "qtile": { - "cargoLocks": null, - "date": "2023-03-31", - "extract": null, - "name": "qtile", - "passthru": null, - "pinned": false, - "src": { - "deepClone": false, - "fetchSubmodules": false, - "leaveDotGit": false, - "name": null, - "owner": "qtile", - "repo": "qtile", - "rev": "e88537fbcce9e8e0de3349c566de4fda9a225e96", - "sha256": "sha256-FEiI7T4whhClb8nCrk+CxlihyMVuM3c6EcnmttPszAU=", - "type": "github" - }, - "version": "e88537fbcce9e8e0de3349c566de4fda9a225e96" - } -} \ No newline at end of file diff --git a/pkgs/_sources/generated.nix b/pkgs/_sources/generated.nix deleted file mode 100644 index 4276fa2..0000000 --- a/pkgs/_sources/generated.nix +++ /dev/null @@ -1,16 +0,0 @@ -# This file was generated by nvfetcher, please do not modify it manually. -{ fetchgit, fetchurl, fetchFromGitHub, dockerTools }: -{ - qtile = { - pname = "qtile"; - version = "e88537fbcce9e8e0de3349c566de4fda9a225e96"; - src = fetchFromGitHub ({ - owner = "qtile"; - repo = "qtile"; - rev = "e88537fbcce9e8e0de3349c566de4fda9a225e96"; - fetchSubmodules = false; - sha256 = "sha256-FEiI7T4whhClb8nCrk+CxlihyMVuM3c6EcnmttPszAU="; - }); - date = "2023-03-31"; - }; -} diff --git a/pkgs/all-packages.nix b/pkgs/all-packages.nix new file mode 100644 index 0000000..895faf0 --- /dev/null +++ b/pkgs/all-packages.nix @@ -0,0 +1,11 @@ +{ pkgs }: +{ + hexagon = pkgs.callPackage ./hexagon.nix { }; + mcaselector = pkgs.callPackage ./mcaselector.nix { }; + nix-modrinth-prefetch = pkgs.callPackage ./nix-modrinth-prefetch.nix { }; + olympus = pkgs.callPackage ./olympus.nix { }; + setris = pkgs.callPackage ./setris.nix { }; + sim65 = pkgs.callPackage ./sim65.nix { }; + substituteSubset = pkgs.callPackage ./substitute-subset.nix { }; + unbted = pkgs.callPackage ./unbted.nix { }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 3df89c8..cbff4fa 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,15 +1,13 @@ -final: prev: { - # keep sources this first - sources = prev.callPackage (import ./_sources/generated.nix) { }; - # then, call packages with `final.callPackage` +{ self, lib, ... }: +{ + perSystem = { pkgs, ... }: + let + allPackages = import ./all-packages.nix { inherit pkgs; }; + in + { + packages = lib.filterAttrs (_: v: lib.isDerivation v) allPackages; + legacyPackages = lib.filterAttrs (_: v: !(lib.isDerivation v)) allPackages; + }; - hexagon = final.callPackage ./hexagon.nix { }; - mcaselector = final.callPackage ./mcaselector.nix { }; - nix-modrinth-prefetch = final.callPackage ./nix-modrinth-prefetch.nix { }; - olympus = final.callPackage ./olympus.nix { }; - qtile-unstable = final.callPackage ./qtile.nix { source = final.sources.qtile; }; - setris = final.callPackage ./setris.nix { }; - sim65 = final.callPackage ./sim65.nix { }; - substituteSubset = final.callPackage ./substitute-subset.nix { }; - unbted = final.callPackage ./unbted.nix { }; + flake.overlays.packages = final: prev: (import ./all-packages.nix { pkgs = prev; }); } diff --git a/pkgs/olympus.nix b/pkgs/olympus.nix index 3172378..8cd878c 100644 --- a/pkgs/olympus.nix +++ b/pkgs/olympus.nix @@ -30,7 +30,7 @@ let }; in buildFHSUserEnv { - name = "olympus"; + inherit (olympus) name; runScript = "${olympus}/opt/olympus/olympus"; targetPkgs = pkgs: [ pkgs.freetype diff --git a/pkgs/patches/qtile-fix-restart.patch b/pkgs/patches/qtile-fix-restart.patch deleted file mode 100644 index eca4f08..0000000 --- a/pkgs/patches/qtile-fix-restart.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/libqtile/core/lifecycle.py b/libqtile/core/lifecycle.py -index 0d4d119d..c37d1799 100644 ---- a/libqtile/core/lifecycle.py -+++ b/libqtile/core/lifecycle.py -@@ -25,7 +25,7 @@ class LifeCycle: - - def _atexit(self) -> None: - if self.behavior is Behavior.RESTART: -- argv = [sys.executable] + sys.argv -+ argv = sys.argv - if "--no-spawn" not in argv: - argv.append("--no-spawn") - argv = [s for s in argv if not s.startswith("--with-state")] -@@ -33,7 +33,7 @@ class LifeCycle: - argv.append("--with-state=" + self.state_file) - logger.warning("Restarting Qtile with os.execv(...)") - # No other code will execute after the following line does -- os.execv(sys.executable, argv) -+ os.execv(sys.argv[0], argv) - elif self.behavior is Behavior.TERMINATE: - logger.warning("Qtile will now terminate") - elif self.behavior is Behavior.NONE: diff --git a/pkgs/qtile.nix b/pkgs/qtile.nix deleted file mode 100644 index c7eceaf..0000000 --- a/pkgs/qtile.nix +++ /dev/null @@ -1,90 +0,0 @@ -{ lib -, fetchFromGitHub -, python3 -, python3Packages -, mypy -, glib -, pango -, pkg-config -, libinput -, libxkbcommon -, wayland -, wlroots -, xcbutilcursor -, source -}: - -let - unwrapped = python3Packages.buildPythonPackage rec { - inherit (source) pname src; - version = "0.0.0+${source.version}"; - - patches = [ - ./patches/qtile-fix-restart.patch # https://github.com/NixOS/nixpkgs/issues/139568 - ]; - - postPatch = '' - substituteInPlace libqtile/pangocffi.py \ - --replace libgobject-2.0.so.0 ${glib.out}/lib/libgobject-2.0.so.0 \ - --replace libpangocairo-1.0.so.0 ${pango.out}/lib/libpangocairo-1.0.so.0 \ - --replace libpango-1.0.so.0 ${pango.out}/lib/libpango-1.0.so.0 - substituteInPlace libqtile/backend/x11/xcursors.py \ - --replace libxcb-cursor.so.0 ${xcbutilcursor.out}/lib/libxcb-cursor.so.0 - ''; - - SETUPTOOLS_SCM_PRETEND_VERSION = version; - - nativeBuildInputs = [ - pkg-config - ] ++ (with python3Packages; [ - setuptools-scm - ]); - - propagatedBuildInputs = with python3Packages; [ - xcffib - (cairocffi.override { withXcffib = true; }) - setuptools - python-dateutil - dbus-python - dbus-next - mpd2 - psutil - pyxdg - pygobject3 - pywayland - pywlroots - xkbcommon - ]; - - buildInputs = [ - libinput - wayland - wlroots - libxkbcommon - ]; - - # for `qtile check`, needs `stubtest` and `mypy` commands - makeWrapperArgs = [ - "--suffix PATH : ${lib.makeBinPath [ mypy ]}" - ]; - - doCheck = false; # Requires X server #TODO this can be worked out with the existing NixOS testing infrastructure. - - meta = with lib; { - homepage = "http://www.qtile.org/"; - license = licenses.mit; - description = "A small, flexible, scriptable tiling window manager written in Python"; - platforms = platforms.linux; - maintainers = with maintainers; [ kamilchm ]; - }; - }; -in -(python3.withPackages (_: [ unwrapped ])).overrideAttrs (_: { - # otherwise will be exported as "env", this restores `nix search` behavior - name = "${unwrapped.pname}-${unwrapped.version}"; - # export underlying qtile package - passthru = { inherit unwrapped; }; - - # restore original qtile attrs - inherit (unwrapped) pname version meta; -}) diff --git a/pkgs/sources.toml b/pkgs/sources.toml deleted file mode 100644 index 2023298..0000000 --- a/pkgs/sources.toml +++ /dev/null @@ -1,4 +0,0 @@ -# nvfetcher toml -[qtile] -src.git = "https://github.com/qtile/qtile.git" -fetch.github = "qtile/qtile" diff --git a/shell/default.nix b/shell/default.nix index ad56e33..e03d3e4 100644 --- a/shell/default.nix +++ b/shell/default.nix @@ -1,6 +1,24 @@ -{ self, inputs, ... }: +{ self, lib, ... }: + { - exportedModules = [ - ./devos.nix - ]; + perSystem = { pkgs, ... }: { + devshells.default = + let + pythonEnv = (pkgs.python310.withPackages (p: with p; [ + pkgs.qtile.passthru.unwrapped + ])); + in + { + devshell.packages = [ + pythonEnv + ]; + + env = [ + { + name = "PYTHONPATH"; + value = "${pythonEnv}/${pythonEnv.sitePackages}"; + } + ]; + }; + }; } diff --git a/shell/devos.nix b/shell/devos.nix deleted file mode 100644 index fcbbec2..0000000 --- a/shell/devos.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ pkgs, extraModulesPath, inputs, ... }: -let - - hooks = import ./hooks; - - pkgWithCategory = category: package: { inherit package category; }; - linter = pkgWithCategory "linter"; - docs = pkgWithCategory "docs"; - devos = pkgWithCategory "devos"; - - pythonEnv = pkgs.python310.withPackages (p: with p; [ - pkgs.qtile.passthru.unwrapped - ]); -in -{ - _file = toString ./.; - - imports = [ "${extraModulesPath}/git/hooks.nix" ]; - git = { inherit hooks; }; - - # tempfix: remove when merged https://github.com/numtide/devshell/pull/123 - devshell.startup.load_profiles = pkgs.lib.mkForce (pkgs.lib.noDepEntry '' - # PATH is devshell's exorbitant privilige: - # fence against its pollution - _PATH=''${PATH} - # Load installed profiles - for file in "$DEVSHELL_DIR/etc/profile.d/"*.sh; do - # If that folder doesn't exist, bash loves to return the whole glob - [[ -f "$file" ]] && source "$file" - done - # Exert exorbitant privilige and leave no trace - export PATH=''${_PATH} - unset _PATH - ''); - - devshell.packages = [ - pythonEnv - ]; - - commands = with pkgs; [ - (devos nixUnstable) - (devos agenix) - { - category = "devos"; - name = pkgs.nvfetcher.pname; - help = pkgs.nvfetcher.meta.description; - command = "cd $PRJ_ROOT/pkgs; ${pkgs.nvfetcher}/bin/nvfetcher -c ./sources.toml $@"; - } - (linter nixpkgs-fmt) - (linter editorconfig-checker) - # (docs python3Packages.grip) too many deps - (docs mdbook) - ] - - ++ lib.optional - (system != "i686-linux") - (devos cachix) - - ; - - env = [ - { - name = "PYTHONPATH"; - value = "${pythonEnv}/${pythonEnv.sitePackages}"; - } - ]; -} diff --git a/shell/hooks/default.nix b/shell/hooks/default.nix deleted file mode 100644 index 10f2c9d..0000000 --- a/shell/hooks/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ - enable = true; - pre-commit.text = builtins.readFile ./pre-commit.sh; -} diff --git a/shell/hooks/pre-commit.sh b/shell/hooks/pre-commit.sh deleted file mode 100755 index 985d3b4..0000000 --- a/shell/hooks/pre-commit.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -if git rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=$(${git}/bin/git hash-object -t tree /dev/null) -fi - -diff="git diff-index --name-only --cached $against --diff-filter d" - -nix_files=($($diff -- '*.nix')) -all_files=($($diff)) - -# Format staged nix files. -if [[ -n "${nix_files[@]}" ]]; then - nixpkgs-fmt "${nix_files[@]}" \ - && git add "${nix_files[@]}" -fi - -# check editorconfig -editorconfig-checker -- "${all_files[@]}" -if [[ $? != '0' ]]; then - printf "%b\n" \ - "\nCode is not aligned with .editorconfig" \ - "Review the output and commit your fixes" >&2 - exit 1 -fi