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": {
"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";
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 = {
self,
nixpkgs,
systems,
...
}: let
inherit (nixpkgs) lib;
genSystems = lib.genAttrs [
"aarch64-linux"
"x86_64-linux"
];
pkgsFor = genSystems (system:
eachSystem = lib.genAttrs (import systems);
pkgsFor = eachSystem (system:
import nixpkgs {
inherit system;
overlays = [self.overlays.default];
localSystem = system;
overlays = [self.overlays.hyprland-protocols];
});
mkDate = longDate: (lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
@ -25,14 +27,18 @@
]);
version = "0.1" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
in {
overlays.default = final: prev: {
hyprland-protocols = final.callPackage ./nix/default.nix {inherit version;};
overlays = {
hyprland-protocols = final: prev: {
hyprland-protocols = final.callPackage ./nix/default.nix {inherit version;};
};
default = self.overlays.hyprland-protocols;
};
packages = genSystems (system:
(self.overlays.default pkgsFor.${system} pkgsFor.${system})
// {default = self.packages.${system}.hyprland-protocols;});
packages = eachSystem (system: {
inherit (pkgsFor.${system}) hyprland-protocols;
default = self.packages.${system}.hyprland-protocols;
});
formatter = genSystems (system: pkgsFor.${system}.alejandra);
formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra);
};
}