Add flake because I hate myself
This commit is contained in:
parent
1cda4fd866
commit
6d6b3179af
6 changed files with 252 additions and 71 deletions
|
@ -1,4 +1,5 @@
|
|||
README.md
|
||||
LICENSE.txt
|
||||
/dist
|
||||
/target
|
||||
/target
|
||||
/result
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
/target
|
||||
/dist
|
||||
.env
|
||||
.vscode
|
||||
.vscode
|
||||
/result
|
19
default.nix
19
default.nix
|
@ -1,19 +0,0 @@
|
|||
{ naersk
|
||||
, version
|
||||
, pkgs
|
||||
, ...
|
||||
}:
|
||||
|
||||
naersk.buildPackage {
|
||||
name = "staxman";
|
||||
inherit version;
|
||||
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
clang
|
||||
mold
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [ ];
|
||||
}
|
148
flake.lock
Normal file
148
flake.lock
Normal file
|
@ -0,0 +1,148 @@
|
|||
{
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1701040486,
|
||||
"narHash": "sha256-vawYwoHA5CwvjfqaT3A5CT9V36Eq43gxdwpux32Qkjw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "45827faa2132b8eade424f6bdd48d8828754341a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681358109,
|
||||
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-crate2nix": "rust-crate2nix",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-crate2nix": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1701048361,
|
||||
"narHash": "sha256-MIAFa7npdx7a3mSXrlzwrxNY7GyfRdEfgLgHzQUjfrA=",
|
||||
"owner": "kolloch",
|
||||
"repo": "crate2nix",
|
||||
"rev": "08a455fb7dee71720a9bb413fe498d5304708380",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "kolloch",
|
||||
"repo": "crate2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701137803,
|
||||
"narHash": "sha256-0LcPAdql5IhQSUXJx3Zna0dYTgdIoYO7zUrsKgiBd04=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "9dd940c967502f844eacea52a61e9596268d4f70",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
100
flake.nix
100
flake.nix
|
@ -1,61 +1,61 @@
|
|||
{
|
||||
description = "staxman";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nix-naersk.url = "github:nix-community/naersk";
|
||||
nixpkgs-mozilla = {
|
||||
url = "github:mozilla/nixpkgs-mozilla";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-crate2nix = {
|
||||
url = "github:kolloch/crate2nix";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self
|
||||
inputs @ { self
|
||||
, nixpkgs
|
||||
, flake-utils
|
||||
, nix-naersk
|
||||
, nixpkgs-mozilla
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
(import nixpkgs-mozilla)
|
||||
];
|
||||
, flake-parts
|
||||
, rust-overlay
|
||||
, rust-crate2nix
|
||||
, ...
|
||||
}: flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
];
|
||||
flake = {
|
||||
nixosModules.default = import ./nixos.nix self;
|
||||
};
|
||||
perSystem = { system, pkgs, ... }:
|
||||
let
|
||||
overlays = [
|
||||
(import rust-overlay)
|
||||
(self: super:
|
||||
let
|
||||
toolchain = super.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
in
|
||||
{
|
||||
rustc = toolchain;
|
||||
})
|
||||
];
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
|
||||
toolchain = (pkgs.rustChannelOf {
|
||||
rustToolchain = ./rust-toolchain.toml;
|
||||
sha256 = "sha256-ks0nMEGGXKrHnfv4Fku+vhQ7gx76ruv6Ij4fKZR3l78=";
|
||||
}).rust;
|
||||
|
||||
naersk = pkgs.callPackage nix-naersk {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
};
|
||||
in
|
||||
{
|
||||
packages = rec {
|
||||
default = staxman;
|
||||
staxman = import ./package.nix {
|
||||
inherit naersk pkgs;
|
||||
version = self.rev or "dirty";
|
||||
project =
|
||||
let
|
||||
crateTools = pkgs.callPackage "${rust-crate2nix}/tools.nix" { inherit pkgs; };
|
||||
in
|
||||
import
|
||||
(crateTools.generatedCargoNix {
|
||||
name = "staxman";
|
||||
src = ./.;
|
||||
})
|
||||
{
|
||||
inherit pkgs;
|
||||
};
|
||||
in
|
||||
rec {
|
||||
packages = {
|
||||
staxman = project.rootCrate.build;
|
||||
default = packages.staxman;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
apps.default = flake-utils.lib.mkApp {
|
||||
drv = self.packages.${system}.default;
|
||||
exePath = "/bin/staxman";
|
||||
};
|
||||
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
|
||||
shell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
arion
|
||||
docker-client
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
50
nixos.nix
Normal file
50
nixos.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
flake: { config
|
||||
, lib
|
||||
, pkgs
|
||||
, ...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf getBin types mkEnableOption mkOption;
|
||||
inherit (flake.packages.${pkgs.stdenv.hostPlatform.system}) staxman;
|
||||
cfg = config.services.staxman;
|
||||
in
|
||||
{
|
||||
options.services.staxman = {
|
||||
enable = mkEnableOption "staxman";
|
||||
stackDir = mkOption {
|
||||
type = types.path;
|
||||
defaultText = "/stacks";
|
||||
example = "/stacks";
|
||||
description = ''
|
||||
Directory containing Arion stacks
|
||||
'';
|
||||
};
|
||||
bindAddress = mkOption
|
||||
{
|
||||
type = types.str;
|
||||
default = "127.0.0.1:3000";
|
||||
description = ''
|
||||
Bind address
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.staxman = {
|
||||
description = "Scatting system management";
|
||||
after = [ "network-online.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment.STAX_ARION_BIN = "${getBin pkgs.arion}";
|
||||
environment.STAX_DIR = cfg.stackDir;
|
||||
environment.STAX_BIND = cfg.bindAddress;
|
||||
|
||||
serviceConfig = {
|
||||
User = "root";
|
||||
Group = "root";
|
||||
Restart = "always";
|
||||
ExecStart = "${getBin staxman}/bin/staxman";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Reference in a new issue