use flake-parts

This commit is contained in:
raf 2023-11-29 00:26:20 +03:00
parent 84735c2cc9
commit 98a817e65a
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
2 changed files with 66 additions and 15 deletions

View file

@ -1,5 +1,23 @@
{ {
"nodes": { "nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1698882062,
"narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "8c9fa2545007b49a5db5f650ae91f227672c3877",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1701189068, "lastModified": 1701189068,
@ -15,8 +33,27 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1698611440,
"narHash": "sha256-jPjHjrerhYDy3q9+s5EAsuhyhuknNfowY6yt6pjn9pc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0cbe9f69c234a7700596e943bfae7ef27a31b735",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View file

@ -1,23 +1,37 @@
{ {
description = "An air quality monitoring service with a Raspberry Pi and a SDS011 sensor."; description = "An air quality monitoring service with a Raspberry Pi and a SDS011 sensor.";
inputs.nixpkgs.url = "github:NixOS/nixpkgs"; inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = { outputs = {
self, self,
nixpkgs, flake-parts,
}: let ...
systems = ["aarch64-linux" "x86_64-linux"]; } @ inputs:
forEachSystem = nixpkgs.lib.genAttrs systems; flake-parts.lib.mkFlake {inherit inputs;} {
pkgsForEach = nixpkgs.legacyPackages; imports = [./nix/tests];
in rec {
packages = forEachSystem (system: {
default = pkgsForEach.${system}.callPackage ./nix {};
});
devShells = forEachSystem (system: { systems = ["x86_64-linux" "aarch64-linux"];
default = pkgsForEach.${system}.callPackage ./nix/shell.nix {}; perSystem = {
}); self',
pkgs,
...
}: {
formatter = pkgs.alejandra;
hydraJobs = packages; packages = {
pi-air-quality-monitor = pkgs.callPackage ./nix/default.nix {};
default = self'.packages.pi-air-quality-monitor;
};
};
flake = {
nixosModules = {
pi-air-quality-monitor = import ./nix/module.nix self;
default = self.nixosModules.pi-air-quality-monitor;
};
};
}; };
} }