Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flakeDir option to automatically set the FLAKE variable #47

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![dependency status](https://deps.rs/repo/github/viperML/nh/status.svg)](https://deps.rs/repo/github/viperML/nh)

<h1 align="center">nh</h1>

<h6 align="center">Because the name "yet-another-<u>n</u>ix-<u>h</u>elper" was too long to type...</h1>
Expand Down
18 changes: 17 additions & 1 deletion module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ self: {
description = "Which NH package to use";
};

flake = mkOption {
type = with types; nullOr path;
default = null;
description = "The path that will be used for the `FLAKE` environment variable";
};

clean = {
enable = mkOption {
type = types.bool;
Expand Down Expand Up @@ -45,9 +51,19 @@ self: {
assertion = config.nh.clean.enable -> config.nh.enable;
message = "nh.clean.enable requires nh.enable";
}

{
assertion = (config.nh.flake != null) -> !(lib.hasSuffix ".nix" config.nh.flake);
message = "nh.flake must be a directory";
}
];

environment.systemPackages = [config.nh.package];
environment = {
systemPackages = [config.nh.package];
variables = lib.optionalAttrs (config.nh.flake != null) {
FLAKE = config.nh.flake;
};
};

systemd = lib.mkIf config.nh.clean.enable {
services.nh-clean = {
Expand Down