Make nix module and overlay system-agnostic

This commit is contained in:
Natsu Kagami 2023-06-20 01:20:54 +02:00
parent 7434f7bc64
commit 4845b9d467
Signed by: nki
GPG key ID: 55A032EB38B49ADB
2 changed files with 42 additions and 44 deletions

View file

@ -10,7 +10,8 @@
extra-substituters = [ "https://natsukagami.cachix.org" ]; extra-substituters = [ "https://natsukagami.cachix.org" ];
trusted-public-keys = [ "natsukagami.cachix.org-1:3U6GV8i8gWEaXRUuXd2S4ASfYgdl2QFPWg4BKPbmYiQ=" ]; trusted-public-keys = [ "natsukagami.cachix.org-1:3U6GV8i8gWEaXRUuXd2S4ASfYgdl2QFPWg4BKPbmYiQ=" ];
}; };
outputs = { self, nixpkgs, flake-utils, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: outputs = { self, nixpkgs, flake-utils, ... }@inputs: flake-utils.lib.eachDefaultSystem
(system:
let let
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
@ -21,12 +22,6 @@
defaultPackage = packages.youmubot; defaultPackage = packages.youmubot;
overlays.default = final: prev: {
youmubot = final.callPackage ./package.nix {
naersk = final.callPackage inputs.naersk { };
};
};
# `nix run` # `nix run`
apps.youmubot = flake-utils.lib.mkApp { apps.youmubot = flake-utils.lib.mkApp {
drv = packages.youmubot; drv = packages.youmubot;
@ -53,8 +48,14 @@
pkg-config pkg-config
]); ]);
}; };
}) // {
overlays.default = final: prev: {
youmubot = final.callPackage ./package.nix {
naersk = final.callPackage inputs.naersk { };
};
};
# module # module
nixosModule = import ./module.nix defaultPackage; nixosModules.default = import ./module.nix;
}); };
} }

View file

@ -1,4 +1,4 @@
youmubot: { config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib; with lib;
let let
@ -7,10 +7,7 @@ in
{ {
options.services.youmubot = { options.services.youmubot = {
enable = mkEnableOption "Enable youmubot, the discord bot made with Rust."; enable = mkEnableOption "Enable youmubot, the discord bot made with Rust.";
package = mkOption { package = mkPackageOption pkgs "youmubot" { };
type = types.package;
default = youmubot;
};
envFile = mkOption { envFile = mkOption {
type = types.path; type = types.path;