diff --git a/flake.lock b/flake.lock index 16c26a4..7811a76 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "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": { "locked": { "lastModified": 1701189068, @@ -15,8 +33,27 @@ "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": { "inputs": { + "flake-parts": "flake-parts", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 0bdda23..e02a7d1 100644 --- a/flake.nix +++ b/flake.nix @@ -1,23 +1,37 @@ { 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 = { self, - nixpkgs, - }: let - systems = ["aarch64-linux" "x86_64-linux"]; - forEachSystem = nixpkgs.lib.genAttrs systems; - pkgsForEach = nixpkgs.legacyPackages; - in rec { - packages = forEachSystem (system: { - default = pkgsForEach.${system}.callPackage ./nix {}; - }); + flake-parts, + ... + } @ inputs: + flake-parts.lib.mkFlake {inherit inputs;} { + imports = [./nix/tests]; - devShells = forEachSystem (system: { - default = pkgsForEach.${system}.callPackage ./nix/shell.nix {}; - }); + systems = ["x86_64-linux" "aarch64-linux"]; + 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; + }; + }; + }; }