caveman/flake.nix

130 lines
3.9 KiB
Nix
Raw Normal View History

2022-11-02 21:49:16 +01:00
{
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 }: {
2022-11-03 19:49:00 +01:00
overlay = final: prev: {
2023-01-22 20:39:29 +01:00
inherit (self.packages.${prev.system})
caveman-hunter caveman-butcher
2023-10-16 00:17:19 +02:00
caveman-gatherer caveman-sieve
caveman-smokestack;
2022-11-03 19:49:00 +01:00
};
nixosModule = self.nixosModules.caveman;
nixosModules.caveman = {
imports = [ ./nixos-module.nix ];
nixpkgs.overlays = [ self.overlay ];
};
nixosConfigurations.example = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
2023-08-08 22:06:06 +02:00
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
];
2022-11-03 19:49:00 +01:00
};
2022-11-02 21:49:16 +01:00
} //
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;
};
2023-08-08 23:23:24 +02:00
src = builtins.filterSource (path: type:
builtins.match ".*\.nix" path == null
) ./.;
2022-11-02 21:49:16 +01:00
in rec {
2022-11-03 17:17:39 +01:00
packages.default = self.packages.${system}.caveman-hunter;
2022-11-02 21:49:16 +01:00
packages.caveman-hunter = naersk-lib.buildPackage rec {
pname = "caveman-hunter";
version = self.lastModifiedDate;
2023-08-08 23:23:24 +02:00
inherit src;
targets = [ pname ];
2022-11-02 21:49:16 +01:00
nativeBuildInputs = with pkgs; [ pkg-config ];
2023-01-22 20:38:19 +01:00
buildInputs = with pkgs; [ openssl systemd ];
};
packages.caveman-butcher = naersk-lib.buildPackage rec {
pname = "caveman-butcher";
version = self.lastModifiedDate;
2023-08-08 23:23:24 +02:00
inherit src;
2023-01-22 20:38:19 +01:00
targets = [ pname ];
nativeBuildInputs = with pkgs; [ pkg-config ];
2022-11-03 17:34:29 +01:00
buildInputs = with pkgs; [ openssl systemd ];
2022-11-02 21:49:16 +01:00
};
packages.caveman-gatherer = naersk-lib.buildPackage rec {
pname = "caveman-gatherer";
version = self.lastModifiedDate;
2023-08-08 23:23:24 +02:00
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/
'';
};
2023-10-16 00:17:19 +02:00
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 ];
};
2022-11-17 00:09:46 +01:00
packages.caveman-smokestack = naersk-lib.buildPackage rec {
pname = "caveman-smokestack";
version = self.lastModifiedDate;
2023-08-08 23:23:24 +02:00
inherit src;
2022-11-17 00:09:46 +01:00
targets = [ pname ];
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl systemd ];
};
2022-11-02 21:49:16 +01:00
# `nix develop`
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
fenix.packages.${system}.rust-analyzer
] ++
(with packages.default; nativeBuildInputs ++ buildInputs);
};
});
}