diff --git a/_outputs.nix b/_outputs.nix index d251fafd..bfbf0ef3 100644 --- a/_outputs.nix +++ b/_outputs.nix @@ -1,6 +1,6 @@ { inputs = let - inherit (import ./inputs) mkDep mkInput extraInputs; + inherit (import ./inputs) mkInput extraInputs; mainInputs = { systems = mkInput { @@ -14,24 +14,24 @@ ref = "nixos-unstable-small"; }; - home-manager = mkDep { + home-manager = mkInput { owner = "nix-community"; repo = "home-manager"; }; - nix-on-droid = mkDep { + nix-on-droid = mkInput { owner = "nix-community"; repo = "nix-on-droid"; inputs.home-manager.follows = "home-manager"; }; - sops-nix = mkDep { + sops-nix = mkInput { owner = "Mic92"; repo = "sops-nix"; }; - secrets = mkDep { + secrets = mkInput { type = "git"; url = "ssh://git@git.nelim.org/matt1432/nixos-secrets"; diff --git a/flake.lock b/flake.lock index edb0073f..90af2980 100644 Binary files a/flake.lock and b/flake.lock differ diff --git a/flake.nix b/flake.nix index aa6073da..c104b96c 100644 Binary files a/flake.nix and b/flake.nix differ diff --git a/inputs/default.nix b/inputs/default.nix index 22dff08c..8adc4f33 100644 --- a/inputs/default.nix +++ b/inputs/default.nix @@ -1,31 +1,31 @@ # TODO: add README let - inherit (import ./lib.nix) mkDep mkInput mkHyprDep mkSrc; + inherit (import ./lib.nix) mkInput mkHyprDep mkSrc; inherit (builtins) listToAttrs map removeAttrs; # Inputs nixTools = { - nix-fast-build = mkDep { + nix-fast-build = mkInput { owner = "Mic92"; repo = "nix-fast-build"; }; - nix-eval-jobs = mkDep { + nix-eval-jobs = mkInput { owner = "nix-community"; repo = "nix-eval-jobs"; }; - nix-index-db = mkDep { + nix-index-db = mkInput { owner = "Mic92"; repo = "nix-index-database"; }; - nh = mkDep { + nh = mkInput { owner = "viperML"; repo = "nh"; }; - nurl = mkDep { + nurl = mkInput { owner = "nix-community"; repo = "nurl"; }; @@ -44,7 +44,7 @@ let repo = "flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; - treefmt-nix = mkDep { + treefmt-nix = mkInput { owner = "numtide"; repo = "treefmt-nix"; }; @@ -52,11 +52,11 @@ let owner = "nix-community"; repo = "lib-aggregate"; }; - nix-github-actions = mkDep { + nix-github-actions = mkInput { owner = "nix-community"; repo = "nix-github-actions"; }; - pre-commit-hooks = mkDep { + pre-commit-hooks = mkInput { owner = "cachix"; repo = "git-hooks.nix"; inputs.flake-compat.follows = "flake-compat"; @@ -64,55 +64,55 @@ let }; overlays = { - nixpkgs-wayland = mkDep { + nixpkgs-wayland = mkInput { owner = "nix-community"; repo = "nixpkgs-wayland"; }; - nix-gaming = mkDep { + nix-gaming = mkInput { owner = "fufexan"; repo = "nix-gaming"; }; }; nvimInputs = { - nixd = mkDep { + nixd = mkInput { owner = "nix-community"; repo = "nixd"; }; }; clusterInputs = { - pcsd = mkDep { + pcsd = mkInput { owner = "matt1432"; repo = "nixos-pcsd"; }; }; serviviInputs = { - minix = mkDep { + minix = mkInput { owner = "matt1432"; repo = "Minix"; }; - pr-tracker = mkDep { + pr-tracker = mkInput { owner = "matt1432"; repo = "pr-tracker"; }; }; nosInputs = { - khepri = mkDep { + khepri = mkInput { owner = "matt1432"; repo = "khepri"; }; - jellyfin-flake = mkDep { + jellyfin-flake = mkInput { owner = "matt1432"; repo = "nixos-jellyfin"; }; - bazarr-bulk = mkDep { + bazarr-bulk = mkInput { owner = "mateoradman"; repo = "bazarr-bulk"; }; @@ -120,16 +120,9 @@ let desktopInputs = { hyprlandInputs = { - hyprutils = mkDep { - owner = "hyprwm"; - repo = "hyprutils"; - }; - - hyprland = mkDep { + hyprland = mkInput { owner = "hyprwm"; repo = "Hyprland"; - - inputs.hyprutils.follows = "hyprutils"; }; hyprland-plugins = mkHyprDep { @@ -142,36 +135,29 @@ let repo = "hyprgrass"; }; - hyprpaper = mkDep { + hyprpaper = mkHyprDep { owner = "hyprwm"; repo = "hyprpaper"; - - inputs = { - hyprgraphics.follows = "hyprland/hyprgraphics"; - hyprlang.follows = "hyprland/hyprlang"; - hyprutils.follows = "hyprland/hyprutils"; - hyprwayland-scanner.follows = "hyprland/hyprwayland-scanner"; - }; }; - grim-hyprland = mkDep { + grim-hyprland = mkInput { owner = "eriedaberrie"; repo = "grim-hyprland"; }; - nixcord = mkDep { + nixcord = mkInput { owner = "kaylorben"; repo = "nixcord"; }; }; agsInputs = { - astal = mkDep { + astal = mkInput { owner = "Aylur"; repo = "astal"; }; - ags = mkDep { + ags = mkInput { owner = "Aylur"; repo = "ags"; @@ -185,12 +171,12 @@ let inputs.astal.follows = "astal"; }; - gtk-session-lock = mkDep { + gtk-session-lock = mkInput { owner = "Cu3PO42"; repo = "gtk-session-lock"; }; - virtualkeyboard-adapter = mkDep { + virtualkeyboard-adapter = mkInput { owner = "horriblename"; repo = "fcitx-virtualkeyboard-adapter"; }; @@ -198,7 +184,7 @@ let }; bbsteamieInputs = { - jovian = mkDep { + jovian = mkInput { owner = "Jovian-Experiments"; repo = "Jovian-NixOS"; }; @@ -400,7 +386,7 @@ let } ]; in { - inherit mkDep mkInput mkSrc; + inherit mkInput mkSrc; extraInputs = { diff --git a/inputs/lib.nix b/inputs/lib.nix index adc160b7..2d5ae8dd 100644 --- a/inputs/lib.nix +++ b/inputs/lib.nix @@ -7,10 +7,20 @@ let sha256 = lock.nodes.nixpkgs.locked.narHash; }}/lib"; - inherit (lib) attrValues findFirst foldl' hasAttr matchAttrs optionalAttrs recursiveUpdate; + inherit (lib) attrNames attrValues findFirst foldl' hasAttr matchAttrs optionalAttrs optionals recursiveUpdate; in rec { recursiveUpdateList = list: foldl' recursiveUpdate {} list; + findInput = info: + findFirst + (x: matchAttrs (removeAttrs info ["inputs"]) (x.original or {})) {} + (attrValues lock.nodes); + + mkFollowsFrom = info: target: follows: + optionalAttrs + (hasAttr target ((findInput info).inputs or {})) + {inputs.${target} = {inherit follows;};}; + /* * From an attrset, returns a flake input that has its type defaulted * to `github` and has some of its inputs following this flake's input @@ -19,34 +29,39 @@ in rec { * It gets information from the `flake.lock` file and can be used thanks * to flakegen */ - 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;}; + mkInput = { + type ? "github", + overrideNixpkgs ? true, + ... + } @ info: let + mkOverride = i: mkFollowsFrom info i i; in - recursiveUpdateList [ - info - {inherit type;} - (mkOverride "systems") - (mkOverride "flake-compat") - (mkOverride "flake-utils") - (mkOverride "flake-parts") - (mkOverride "lib-aggregate") - (mkOverride "nix-eval-jobs") - (mkOverride "nix-github-actions") - (mkOverride "pre-commit-hooks") - (mkOverride "treefmt-nix") - ]; + recursiveUpdateList ([ + (removeAttrs info ["overrideNixpkgs"]) + {inherit type;} - mkDep = info: mkInput (recursiveUpdate info {inputs.nixpkgs.follows = "nixpkgs";}); + # Generic inputs + (mkOverride "systems") + (mkOverride "flake-compat") + (mkOverride "flake-utils") + (mkOverride "flake-parts") + (mkOverride "lib-aggregate") + (mkOverride "nix-eval-jobs") + (mkOverride "nix-github-actions") + (mkOverride "pre-commit-hooks") + (mkOverride "treefmt-nix") + ] + # Specify if we can't make an input use this flake's nixpkgs + ++ optionals overrideNixpkgs [(mkOverride "nixpkgs")]); - mkHyprDep = info: mkInput (recursiveUpdate info {inputs.hyprland.follows = "hyprland";}); + mkHyprDep = info: let + inherit (lock.nodes) hyprland; + + mkOverride = i: mkFollowsFrom info i i; + mkHyprOverride = i: mkFollowsFrom info i "hyprland/${i}"; + in + mkInput (recursiveUpdateList ([info (mkOverride "hyprland")] + ++ (map mkHyprOverride (attrNames hyprland.inputs)))); mkSrc = info: mkInput (info // {flake = false;}); }