From 9ea4b26421a639e84b2b931d7290a595f19d71a5 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Tue, 6 Aug 2024 13:27:06 -0400 Subject: [PATCH] feat(flake): use nix-systems and make sure all inputs use the same one --- flake.lock | 335 ++++++++-------------------------------------------- flake.nix | 64 +++++++--- inputs.nix | 79 +++++++------ outputs.nix | 10 +- 4 files changed, 147 insertions(+), 341 deletions(-) diff --git a/flake.lock b/flake.lock index 25411f4a..3fa7aea4 100644 --- a/flake.lock +++ b/flake.lock @@ -1,25 +1,5 @@ { "nodes": { - "Hyprspace": { - "inputs": { - "hyprland": [ - "hyprland" - ] - }, - "locked": { - "lastModified": 1722863918, - "narHash": "sha256-iCigW2j6FlULFYpMzY6LM/O7zB+bCa55ThB4OYf3biI=", - "owner": "KZDKM", - "repo": "Hyprspace", - "rev": "d7785bcfe493f0696dad11baf1a8048aeb39953e", - "type": "github" - }, - "original": { - "owner": "KZDKM", - "repo": "Hyprspace", - "type": "github" - } - }, "Vencord-src": { "flake": false, "locked": { @@ -41,7 +21,9 @@ "nixpkgs": [ "nixpkgs" ], - "systems": "systems" + "systems": [ + "systems" + ] }, "locked": { "lastModified": 1721306136, @@ -274,22 +256,6 @@ } }, "flake-compat": { - "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_2": { "locked": { "lastModified": 1717312683, "narHash": "sha256-FrlieJH50AuvagamEvWMIE6D2OAnERuDboFDYAED/dE=", @@ -306,7 +272,7 @@ }, "flake-parts": { "inputs": { - "nixpkgs-lib": "nixpkgs-lib" + "nixpkgs-lib": "nixpkgs-lib_2" }, "locked": { "lastModified": 1714641030, @@ -324,7 +290,7 @@ }, "flake-parts_2": { "inputs": { - "nixpkgs-lib": "nixpkgs-lib_2" + "nixpkgs-lib": "nixpkgs-lib_3" }, "locked": { "lastModified": 1722555600, @@ -342,7 +308,7 @@ }, "flake-parts_3": { "inputs": { - "nixpkgs-lib": "nixpkgs-lib_3" + "nixpkgs-lib": "nixpkgs-lib_4" }, "locked": { "lastModified": 1714606777, @@ -397,43 +363,9 @@ }, "flake-utils": { "inputs": { - "systems": "systems_4" - }, - "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_2": { - "inputs": { - "systems": "systems_6" - }, - "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_3": { - "inputs": { - "systems": "systems_7" + "systems": [ + "systems" + ] }, "locked": { "lastModified": 1710146030, @@ -451,7 +383,9 @@ }, "flakegen": { "inputs": { - "systems": "systems_2" + "systems": [ + "systems" + ] }, "locked": { "lastModified": 1707120544, @@ -483,28 +417,6 @@ "type": "github" } }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "mozilla-addons-to-nix", - "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" - } - }, "gpu-screen-recorder-src": { "flake": false, "locked": { @@ -526,7 +438,9 @@ "nixpkgs": [ "nixpkgs" ], - "systems": "systems_3" + "systems": [ + "systems" + ] }, "locked": { "lastModified": 1715315063, @@ -580,7 +494,9 @@ }, "headscale": { "inputs": { - "flake-utils": "flake-utils", + "flake-utils": [ + "flake-utils" + ], "nixpkgs": [ "nixpkgs" ] @@ -678,7 +594,9 @@ "nixpkgs": [ "nixpkgs" ], - "systems": "systems_5", + "systems": [ + "systems" + ], "xdph": "xdph" }, "locked": { @@ -708,8 +626,6 @@ "nixpkgs" ], "systems": [ - "hyprland-plugins", - "hyprland", "systems" ] }, @@ -896,8 +812,10 @@ }, "lib-aggregate": { "inputs": { - "flake-utils": "flake-utils_3", - "nixpkgs-lib": "nixpkgs-lib_4" + "flake-utils": [ + "flake-utils" + ], + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { "lastModified": 1722773431, @@ -966,28 +884,6 @@ "type": "github" } }, - "mozilla-addons-to-nix": { - "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": [ - "nixpkgs" - ], - "pre-commit-hooks": "pre-commit-hooks" - }, - "locked": { - "lastModified": 1713544430, - "narHash": "sha256-+3IaEnhhefaj5zoNPkvAx8MM95O930d7sooAmtVuIME=", - "owner": "~rycee", - "repo": "mozilla-addons-to-nix", - "rev": "ed843cef648718519cf9fb89afcb33d7c53411d5", - "type": "sourcehut" - }, - "original": { - "owner": "~rycee", - "repo": "mozilla-addons-to-nix", - "type": "sourcehut" - } - }, "mpv-persist-properties-src": { "flake": false, "locked": { @@ -1330,6 +1226,21 @@ } }, "nixpkgs-lib": { + "locked": { + "lastModified": 1722732880, + "narHash": "sha256-do2Mfm3T6SR7a5A804RhjQ+JTsF5hk4JTPGjCTRM/m8=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "8bebd4c74f368aacb047f0141db09ec6b339733c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-lib_2": { "locked": { "lastModified": 1714640452, "narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=", @@ -1341,7 +1252,7 @@ "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" } }, - "nixpkgs-lib_2": { + "nixpkgs-lib_3": { "locked": { "lastModified": 1722555339, "narHash": "sha256-uFf2QeW7eAHlYXuDktm9c25OxOyCoUOQmh5SZ9amE5Q=", @@ -1353,7 +1264,7 @@ "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" } }, - "nixpkgs-lib_3": { + "nixpkgs-lib_4": { "locked": { "dir": "lib", "lastModified": 1714253743, @@ -1371,38 +1282,7 @@ "type": "github" } }, - "nixpkgs-lib_4": { - "locked": { - "lastModified": 1722732880, - "narHash": "sha256-do2Mfm3T6SR7a5A804RhjQ+JTsF5hk4JTPGjCTRM/m8=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "8bebd4c74f368aacb047f0141db09ec6b339733c", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, "nixpkgs-stable": { - "locked": { - "lastModified": 1710695816, - "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "614b4613980a522ba49f0d194531beddbb7220d3", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-23.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-stable_2": { "locked": { "lastModified": 1721524707, "narHash": "sha256-5NctRsoE54N86nWd0psae70YSLfrOek3Kv1e8KoXe/0=", @@ -1420,8 +1300,10 @@ }, "nixpkgs-wayland": { "inputs": { - "flake-compat": "flake-compat_2", - "lib-aggregate": "lib-aggregate", + "flake-compat": "flake-compat", + "lib-aggregate": [ + "lib-aggregate" + ], "nix-eval-jobs": "nix-eval-jobs", "nixpkgs": [ "nixpkgs" @@ -1638,34 +1520,6 @@ "type": "github" } }, - "pre-commit-hooks": { - "inputs": { - "flake-compat": "flake-compat", - "flake-utils": [ - "mozilla-addons-to-nix", - "flake-utils" - ], - "gitignore": "gitignore", - "nixpkgs": [ - "mozilla-addons-to-nix", - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable" - }, - "locked": { - "lastModified": 1712897695, - "narHash": "sha256-nMirxrGteNAl9sWiOhoN5tIHyjBbVi5e2tgZUgZlK3Y=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "40e6053ecb65fcbf12863338a6dcefb3f55f1bf8", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, "protonhax-src": { "flake": false, "locked": { @@ -1684,7 +1538,6 @@ }, "root": { "inputs": { - "Hyprspace": "Hyprspace", "ags": "ags", "astal-tray": "astal-tray", "bat-theme-src": "bat-theme-src", @@ -1694,6 +1547,7 @@ "dracula-plymouth-src": "dracula-plymouth-src", "eisa-scripts-src": "eisa-scripts-src", "firefox-gx-src": "firefox-gx-src", + "flake-utils": "flake-utils", "flakegen": "flakegen", "git-theme-src": "git-theme-src", "gpu-screen-recorder-src": "gpu-screen-recorder-src", @@ -1708,10 +1562,10 @@ "jellyfin-flake": "jellyfin-flake", "jovian": "jovian", "khepri": "khepri", + "lib-aggregate": "lib-aggregate", "libratbag-src": "libratbag-src", "minix": "minix", "modernx-src": "modernx-src", - "mozilla-addons-to-nix": "mozilla-addons-to-nix", "mpv-persist-properties-src": "mpv-persist-properties-src", "mpv-pointer-event-src": "mpv-pointer-event-src", "mpv-touch-gestures-src": "mpv-touch-gestures-src", @@ -1736,6 +1590,7 @@ "sioyek-theme-src": "sioyek-theme-src", "sops-nix": "sops-nix", "subsync": "subsync", + "systems": "systems", "trash-d-src": "trash-d-src", "ts-for-gir-src": "ts-for-gir-src", "vimplugin-easytables-src": "vimplugin-easytables-src", @@ -1823,7 +1678,7 @@ "nixpkgs": [ "nixpkgs" ], - "nixpkgs-stable": "nixpkgs-stable_2" + "nixpkgs-stable": "nixpkgs-stable" }, "locked": { "lastModified": 1722114803, @@ -1894,96 +1749,6 @@ "type": "github" } }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_3": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "systems_4": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_5": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "systems_6": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_7": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "trash-d-src": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 2aaeb149..e3049f65 100644 --- a/flake.nix +++ b/flake.nix @@ -1,14 +1,11 @@ # Do not modify! This file is generated. { inputs = { - Hyprspace = { - inputs.hyprland.follows = "hyprland"; - owner = "KZDKM"; - repo = "Hyprspace"; - type = "github"; - }; ags = { - inputs.nixpkgs.follows = "nixpkgs"; + inputs = { + nixpkgs.follows = "nixpkgs"; + systems.follows = "systems"; + }; owner = "Aylur"; repo = "ags"; type = "github"; @@ -62,7 +59,16 @@ rev = "9afe9948758871f3944e8a83046c8a51039e883a"; type = "github"; }; - flakegen.url = "github:jorsn/flakegen"; + flake-utils = { + inputs.systems.follows = "systems"; + owner = "numtide"; + repo = "flake-utils"; + type = "github"; + }; + flakegen = { + inputs.systems.follows = "systems"; + url = "github:jorsn/flakegen"; + }; git-theme-src = { flake = false; owner = "dracula"; @@ -75,7 +81,10 @@ url = "https://repo.dec05eba.com/gpu-screen-recorder"; }; grim-hyprland = { - inputs.nixpkgs.follows = "nixpkgs"; + inputs = { + nixpkgs.follows = "nixpkgs"; + systems.follows = "systems"; + }; owner = "eriedaberrie"; repo = "grim-hyprland"; type = "github"; @@ -93,7 +102,10 @@ type = "github"; }; headscale = { - inputs.nixpkgs.follows = "nixpkgs"; + inputs = { + flake-utils.follows = "flake-utils"; + nixpkgs.follows = "nixpkgs"; + }; owner = "juanfont"; repo = "headscale"; type = "github"; @@ -111,13 +123,19 @@ type = "github"; }; hyprland = { - inputs.nixpkgs.follows = "nixpkgs"; + inputs = { + nixpkgs.follows = "nixpkgs"; + systems.follows = "systems"; + }; submodules = true; type = "git"; url = "https://github.com/hyprwm/Hyprland"; }; hyprland-plugins = { - inputs.hyprland.follows = "hyprland"; + inputs = { + hyprland.follows = "hyprland"; + systems.follows = "systems"; + }; owner = "hyprwm"; repo = "hyprland-plugins"; type = "github"; @@ -140,6 +158,12 @@ repo = "khepri"; type = "github"; }; + lib-aggregate = { + inputs.flake-utils.follows = "flake-utils"; + owner = "nix-community"; + repo = "lib-aggregate"; + type = "github"; + }; libratbag-src = { flake = false; owner = "libratbag"; @@ -158,12 +182,6 @@ repo = "ModernX"; type = "github"; }; - mozilla-addons-to-nix = { - inputs.nixpkgs.follows = "nixpkgs"; - owner = "~rycee"; - repo = "mozilla-addons-to-nix"; - type = "sourcehut"; - }; mpv-persist-properties-src = { flake = false; owner = "d87"; @@ -234,7 +252,10 @@ type = "github"; }; nixpkgs-wayland = { - inputs.nixpkgs.follows = "nixpkgs"; + inputs = { + lib-aggregate.follows = "lib-aggregate"; + nixpkgs.follows = "nixpkgs"; + }; owner = "nix-community"; repo = "nixpkgs-wayland"; type = "github"; @@ -314,6 +335,11 @@ rev = "ee9e1592ae4ec7c694d8857aa72be079d81ea209"; type = "github"; }; + systems = { + owner = "nix-systems"; + repo = "default-linux"; + type = "github"; + }; trash-d-src = { flake = false; owner = "rushsteve1"; diff --git a/inputs.nix b/inputs.nix index 682074e5..fc068e72 100644 --- a/inputs.nix +++ b/inputs.nix @@ -1,30 +1,36 @@ let - inherit (builtins) listToAttrs map removeAttrs; + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + lib = import "${builtins.fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/${lock.nodes.nixpkgs.locked.rev}.tar.gz"; + sha256 = lock.nodes.nixpkgs.locked.narHash; + }}/lib"; + + inherit (lib) attrValues findFirst foldl' hasAttr listToAttrs matchAttrs map optionalAttrs recursiveUpdate removeAttrs; + + recursiveUpdateList = list: foldl' recursiveUpdate {} list; # Misc functions - mkInput = {type ? "github", ...} @ info: info // {inherit type;}; - mkDep = info: - mkInput (info - // { - inputs = - {nixpkgs.follows = "nixpkgs";} - // ( - if builtins.hasAttr "inputs" info - then info.inputs - else {} - ); - }); - mkHyprDep = info: - mkInput (info - // { - inputs = - {hyprland.follows = "hyprland";} - // ( - if builtins.hasAttr "inputs" info - then info.inputs - else {} - ); - }); + mkInput = {type ? "github", ...} @ info: let + input = + findFirst + (x: matchAttrs (removeAttrs info ["inputs"]) (x.original or {})) {} + (attrValues lock.nodes); + + mkOverride = i: + optionalAttrs + (hasAttr i (input.inputs or {})) + {inputs.${i}.follows = i;}; + in + recursiveUpdateList [ + info + {inherit type;} + (mkOverride "systems") + (mkOverride "flake-utils") + (mkOverride "lib-aggregate") + ]; + + mkDep = info: mkInput (recursiveUpdate info {inputs.nixpkgs.follows = "nixpkgs";}); + mkHyprDep = info: mkInput (recursiveUpdate info {inputs.hyprland.follows = "hyprland";}); mkSrc = info: mkInput (info // {flake = false;}); # Inputs @@ -54,10 +60,14 @@ let repo = "nix-melt"; }; - mozilla-addons-to-nix = mkDep { - type = "sourcehut"; - owner = "~rycee"; - repo = "mozilla-addons-to-nix"; + # These are here to make sure all 'systems' are the same + flake-utils = mkInput { + owner = "numtide"; + repo = "flake-utils"; + }; + lib-aggregate = mkInput { + owner = "nix-community"; + repo = "lib-aggregate"; }; }; @@ -151,11 +161,6 @@ let # path = "/home/matt/git/hyprland-plugins"; }; - Hyprspace = mkHyprDep { - owner = "KZDKM"; - repo = "Hyprspace"; - }; - hyprgrass = mkHyprDep { owner = "horriblename"; repo = "hyprgrass"; @@ -304,7 +309,13 @@ in { inherit mkDep mkInput mkSrc; otherInputs = - nixTools + { + flakegen = { + url = "github:jorsn/flakegen"; + inputs.systems.follows = "systems"; + }; + } + // nixTools // overlays // nvimInputs // clusterInputs diff --git a/outputs.nix b/outputs.nix index 49cf57ae..ae32c52d 100644 --- a/outputs.nix +++ b/outputs.nix @@ -3,6 +3,11 @@ inherit (import ./inputs.nix) mkDep mkInput otherInputs; mainInputs = { + systems = mkInput { + owner = "nix-systems"; + repo = "default-linux"; + }; + nixpkgs = mkInput { owner = "NixOS"; repo = "nixpkgs"; @@ -45,14 +50,13 @@ nixpkgs, secrets, self, + systems, ... }: let inherit (import "${self}/lib.nix" inputs) mkVersion mkNixOS mkNixOnDroid mkPkgs; - supportedSystems = ["x86_64-linux" "aarch64-linux"]; - perSystem = attrs: - nixpkgs.lib.genAttrs supportedSystems (system: + nixpkgs.lib.genAttrs (import systems) (system: attrs (mkPkgs system nixpkgs)); in { nixosModules = import ./nixosModules self;