Skip to content

Commit

Permalink
nix-init: add module
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter committed May 7, 2024
1 parent 6e277d9 commit 39a3f73
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
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;
};
};
}

0 comments on commit 39a3f73

Please sign in to comment.