{ inputs = { utils.url = "github:numtide/flake-utils"; naersk.url = "github:nmattia/naersk"; naersk.inputs.nixpkgs.follows = "nixpkgs"; fenix.url = "github:nix-community/fenix"; fenix.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, utils, fenix, naersk }: { overlay = final: prev: { inherit (self.packages.${prev.system}) caveman-hunter caveman-butcher caveman-gatherer caveman-sieve caveman-smokestack; }; nixosModule = self.nixosModules.caveman; nixosModules.caveman = { imports = [ ./nixos-module.nix ]; nixpkgs.overlays = [ self.overlay ]; }; nixosConfigurations.example = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ (nixpkgs + "/nixos/modules/virtualisation/qemu-vm.nix") { networking.hostName = "example"; users.users.root.initialPassword = ""; services.caveman.hunter = { enable = true; logLevel = "TRACE"; }; services.caveman.gatherer = { enable = true; logLevel = "TRACE"; }; virtualisation.forwardPorts = [ { # proto = "tcp"; from = "host"; # host.address = "0.0.0.0"; host.port = 8000; # guest.address = "10.0.2.15"; guest.port = 8000; } ]; networking.firewall.allowedTCPPorts = [ 8000 ]; } self.nixosModule ]; }; } // utils.lib.eachSystem (with utils.lib.system; [ x86_64-linux aarch64-linux ]) (system: let pkgs = nixpkgs.legacyPackages.${system}; rust = fenix.packages.${system}.stable.withComponents [ "cargo" "rustc" "rust-src" # just for rust-analyzer "clippy" ]; # Override the version used in naersk naersk-lib = naersk.lib."${system}".override { cargo = rust; rustc = rust; }; src = builtins.filterSource (path: type: builtins.match ".*\.nix" path == null ) ./.; in rec { packages.default = self.packages.${system}.caveman-hunter; packages.caveman-hunter = naersk-lib.buildPackage rec { pname = "caveman-hunter"; version = self.lastModifiedDate; inherit src; targets = [ pname ]; nativeBuildInputs = with pkgs; [ pkg-config ]; buildInputs = with pkgs; [ openssl systemd ]; }; packages.caveman-butcher = naersk-lib.buildPackage rec { pname = "caveman-butcher"; version = self.lastModifiedDate; inherit src; targets = [ pname ]; nativeBuildInputs = with pkgs; [ pkg-config ]; buildInputs = with pkgs; [ openssl systemd ]; }; packages.caveman-gatherer = naersk-lib.buildPackage rec { pname = "caveman-gatherer"; version = self.lastModifiedDate; inherit src; targets = [ pname ]; nativeBuildInputs = with pkgs; [ pkg-config ]; buildInputs = with pkgs; [ openssl systemd ]; postInstall = '' mkdir -p $out/share/caveman/gatherer cp -rv gatherer/{templates,assets} $out/share/caveman/gatherer/ ''; }; packages.caveman-sieve = naersk-lib.buildPackage rec { pname = "caveman-sieve"; version = self.lastModifiedDate; inherit src; targets = [ pname ]; nativeBuildInputs = with pkgs; [ pkg-config ]; buildInputs = with pkgs; [ openssl systemd ]; }; packages.caveman-smokestack = naersk-lib.buildPackage rec { pname = "caveman-smokestack"; version = self.lastModifiedDate; inherit src; targets = [ pname ]; nativeBuildInputs = with pkgs; [ pkg-config ]; buildInputs = with pkgs; [ openssl systemd ]; }; # `nix develop` devShells.default = pkgs.mkShell { nativeBuildInputs = [ fenix.packages.${system}.rust-analyzer ] ++ (with packages.default; nativeBuildInputs ++ buildInputs); }; }); }