Actually pass the flake build

This commit is contained in:
Juno Takano 2026-06-21 18:40:15 -03:00
commit fc5498ef29
No known key found for this signature in database

111
flake.nix
View file

@ -1,80 +1,99 @@
# Note this is just a draft, not properly tested or documented yet
{ {
description = "A non-linear writing instrument."; description = "A non-linear writing instrument.";
inputs.nixpkgs.url = "nixpkgs/nixos-26.05"; inputs.nixpkgs.url = "nixpkgs/nixos-26.05";
outputs = { nixpkgs, self }: let outputs = { nixpkgs, self }: let
name = "en"; name = "en";
version = "0.4.0"; version = "0.4.0-alpha";
supportedSystems = [ supportedSystems = [
"x86_64-linux" "x86_64-linux"
"aarch64-linux"
]; ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
nixpkgsFor = forAllSystems (system: import nixpkgs {
inherit system;
});
in { in {
packages = forAllSystems (system: let packages = forAllSystems (system: let pkgs = nixpkgsFor.${system};
pkgs = nixpkgsFor.${system};
in { in {
default = pkgs.rustPlatform.buildRustPackage { default = pkgs.rustPlatform.buildRustPackage {
inherit name version; inherit name version;
src = ./.; src = ./.;
nativeBuildInputs = with pkgs; [
just
];
dontUseJustInstall = true;
dontUseJustBuild = true;
cargoHash = cargoHash =
"sha256-" "sha256-U6jf48KmqcdCBYKyZhYPpiv5qj98SjlNqw8Ii2mJn0I=";
+ "em229cShq/IShRnxlp5mgcIu7pIOf0LflV8Pw0lLUEY=";
};
});
apps = forAllSystems (system: {
default = {
type = "app";
program =
"${self.packages.${system}.default}/bin/en";
}; };
}); });
devShells = forAllSystems (system: devShells = forAllSystems (system:
let pkgs = nixpkgsFor.${system}; in { let
default = pkgs.mkShell { pkgs = nixpkgsFor.${system};
buildInputs = with pkgs; [ base = with pkgs; [
rustup rustup
just just
watchexec watchexec
cargo-deny cargo-deny
cargo-llvm-cov cargo-llvm-cov
cargo-mutants cargo-mutants
go-tools cargo-msrv
typos typos
taplo taplo
];
in {
default = pkgs.mkShell { buildInputs = base; };
cross = pkgs.mkShell {
buildInputs = with pkgs; base ++ [
cargo-xwin
wine
]; ];
}; };
} }
); );
nixosModules.en = { config, lib, system, ... }:
nixosModules.bot = { config, lib, system, ... }: { {
options.within.services.en.enable = options.within.services.en = {
lib.mkEnableOption "enable en server"; enable = lib.mkEnableOption "enable en server";
port = lib.mkOption {
config = lib.mkIf config.within.services.en.enable { description = "Port to serve your graph on";
systemd.services.en = { defaultText = "A random port chosen by the OS";
wantedBy = [ "multi-user.target" ]; type = lib.types.port;
serviceConfig = { };
Restart = "always"; host = lib.mkOption {
ExecStart = description = "Address or hostname to serve your graph on";
"${self.packages."${system}".default}/bin/en"; default = "0.0.0.0";
type = lib.types.str;
};
graph = lib.mkOption {
description = "File path pointing to your graph file";
default = "./static/graph.toml";
type = lib.types.path;
}; };
}; };
};
};
config =
lib.mkIf config.within.services.en.enable {
systemd.services.en = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Restart = "always";
ExecStart = let
user_opts = config.within.services.en;
in
"${self.packages.${system}.default}/bin/en"
+ " --port ${user_opts.port}"
+ " --host ${user_opts.host}"
+ " --graph ${user_opts.graph}";
};
};
};
};
}; };
} }