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

nix-init: add module #5380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,13 @@ in {
between windows, and is also a widget engine.
'';
}

{
time = "2024-05-07T16:33:07+00:00";
message = ''
A new module is available: 'programs.nix-init'.
'';
}
];
};
}
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ let
./programs/newsboat.nix
./programs/nheko.nix
./programs/nix-index.nix
./programs/nix-init.nix
./programs/nnn.nix
./programs/noti.nix
./programs/notmuch.nix
Expand Down
57 changes: 57 additions & 0 deletions modules/programs/nix-init.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{ config, lib, pkgs, ... }:
let tomlFormat = pkgs.formats.toml { };
in with lib; {
meta.maintainers = [ maintainers.uncenter ];

options.programs.nix-init = {
enable = mkEnableOption
"nix-init - Generate Nix packages from URLs with hash prefetching, dependency inference, license detection, and more";

settings = mkOption {
type = tomlFormat.type;
default = { };
example = lib.literalExpression ''
{
maintainers = [
"figsoda"
];
nixpkgs = "<nixpkgs>";
commit = true;
access-tokens = {
github.com = "ghp_blahblahblah...";
gitlab.com = {
command = [
"secret-tool"
"or"
"whatever"
"you"
"use"
];
};
gitlab.gnome.org = {
file = "/path/to/api/token";
};
};
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/nix-init/config.toml`.

See <https://github.com/nix-community/nix-init#configuration> for the full list
of options.
'';
};

package = lib.mkPackageOption pkgs "nix-init" { };
};

config = let cfg = config.programs.nix-init;
in mkIf cfg.enable {
home.packages = [ cfg.package ];

xdg.configFile."nix-init/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "config.toml" cfg.settings;
};
};
}