feat(flake): use nix-systems and make sure all inputs use the same one
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-08-06 13:27:06 -04:00
parent c5c1dfe63b
commit 9ea4b26421
4 changed files with 52 additions and 37 deletions

Binary file not shown.

BIN
flake.nix

Binary file not shown.

View file

@ -1,30 +1,36 @@
let 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 # Misc functions
mkInput = {type ? "github", ...} @ info: info // {inherit type;}; mkInput = {type ? "github", ...} @ info: let
mkDep = info: input =
mkInput (info findFirst
// { (x: matchAttrs (removeAttrs info ["inputs"]) (x.original or {})) {}
inputs = (attrValues lock.nodes);
{nixpkgs.follows = "nixpkgs";}
// ( mkOverride = i:
if builtins.hasAttr "inputs" info optionalAttrs
then info.inputs (hasAttr i (input.inputs or {}))
else {} {inputs.${i}.follows = i;};
); in
}); recursiveUpdateList [
mkHyprDep = info: info
mkInput (info {inherit type;}
// { (mkOverride "systems")
inputs = (mkOverride "flake-utils")
{hyprland.follows = "hyprland";} (mkOverride "lib-aggregate")
// ( ];
if builtins.hasAttr "inputs" info
then info.inputs mkDep = info: mkInput (recursiveUpdate info {inputs.nixpkgs.follows = "nixpkgs";});
else {} mkHyprDep = info: mkInput (recursiveUpdate info {inputs.hyprland.follows = "hyprland";});
);
});
mkSrc = info: mkInput (info // {flake = false;}); mkSrc = info: mkInput (info // {flake = false;});
# Inputs # Inputs
@ -54,10 +60,14 @@ let
repo = "nix-melt"; repo = "nix-melt";
}; };
mozilla-addons-to-nix = mkDep { # These are here to make sure all 'systems' are the same
type = "sourcehut"; flake-utils = mkInput {
owner = "~rycee"; owner = "numtide";
repo = "mozilla-addons-to-nix"; repo = "flake-utils";
};
lib-aggregate = mkInput {
owner = "nix-community";
repo = "lib-aggregate";
}; };
}; };
@ -151,11 +161,6 @@ let
# path = "/home/matt/git/hyprland-plugins"; # path = "/home/matt/git/hyprland-plugins";
}; };
Hyprspace = mkHyprDep {
owner = "KZDKM";
repo = "Hyprspace";
};
hyprgrass = mkHyprDep { hyprgrass = mkHyprDep {
owner = "horriblename"; owner = "horriblename";
repo = "hyprgrass"; repo = "hyprgrass";
@ -304,7 +309,13 @@ in {
inherit mkDep mkInput mkSrc; inherit mkDep mkInput mkSrc;
otherInputs = otherInputs =
nixTools {
flakegen = {
url = "github:jorsn/flakegen";
inputs.systems.follows = "systems";
};
}
// nixTools
// overlays // overlays
// nvimInputs // nvimInputs
// clusterInputs // clusterInputs

View file

@ -3,6 +3,11 @@
inherit (import ./inputs.nix) mkDep mkInput otherInputs; inherit (import ./inputs.nix) mkDep mkInput otherInputs;
mainInputs = { mainInputs = {
systems = mkInput {
owner = "nix-systems";
repo = "default-linux";
};
nixpkgs = mkInput { nixpkgs = mkInput {
owner = "NixOS"; owner = "NixOS";
repo = "nixpkgs"; repo = "nixpkgs";
@ -45,14 +50,13 @@
nixpkgs, nixpkgs,
secrets, secrets,
self, self,
systems,
... ...
}: let }: let
inherit (import "${self}/lib.nix" inputs) mkVersion mkNixOS mkNixOnDroid mkPkgs; inherit (import "${self}/lib.nix" inputs) mkVersion mkNixOS mkNixOnDroid mkPkgs;
supportedSystems = ["x86_64-linux" "aarch64-linux"];
perSystem = attrs: perSystem = attrs:
nixpkgs.lib.genAttrs supportedSystems (system: nixpkgs.lib.genAttrs (import systems) (system:
attrs (mkPkgs system nixpkgs)); attrs (mkPkgs system nixpkgs));
in { in {
nixosModules = import ./nixosModules self; nixosModules = import ./nixosModules self;