Nix: corrections for overlays, overrideable system (#6)

* flake: change formatter to use legacyPackages

* flake: add overlay with explicit name

* flake: make systems overrideable

* flake: inherit packages from pkgsFor
This commit is contained in:
Jacob Birkett 2023-08-11 06:36:36 -05:00 committed by GitHub
parent 8c279b9fb0
commit 0c2ce70625
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 15 deletions

View File

@ -18,7 +18,23 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"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"
} }
} }
}, },

View File

@ -1,22 +1,24 @@
{ {
description = "Hyprland Protocols"; description = "Hyprland Protocols";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# <https://github.com/nix-systems/nix-systems>
systems.url = "github:nix-systems/default-linux";
};
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
systems,
... ...
}: let }: let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
genSystems = lib.genAttrs [ eachSystem = lib.genAttrs (import systems);
"aarch64-linux" pkgsFor = eachSystem (system:
"x86_64-linux"
];
pkgsFor = genSystems (system:
import nixpkgs { import nixpkgs {
inherit system; localSystem = system;
overlays = [self.overlays.default]; overlays = [self.overlays.hyprland-protocols];
}); });
mkDate = longDate: (lib.concatStringsSep "-" [ mkDate = longDate: (lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate) (builtins.substring 0 4 longDate)
@ -25,14 +27,18 @@
]); ]);
version = "0.1" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); version = "0.1" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
in { in {
overlays.default = final: prev: { overlays = {
hyprland-protocols = final.callPackage ./nix/default.nix {inherit version;}; hyprland-protocols = final: prev: {
hyprland-protocols = final.callPackage ./nix/default.nix {inherit version;};
};
default = self.overlays.hyprland-protocols;
}; };
packages = genSystems (system: packages = eachSystem (system: {
(self.overlays.default pkgsFor.${system} pkgsFor.${system}) inherit (pkgsFor.${system}) hyprland-protocols;
// {default = self.packages.${system}.hyprland-protocols;}); default = self.packages.${system}.hyprland-protocols;
});
formatter = genSystems (system: pkgsFor.${system}.alejandra); formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra);
}; };
} }