Skip to content

Commit

Permalink
nixup: add module: nixup-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
ts468 committed Nov 16, 2017
1 parent 55dc7ac commit 3deede4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixup/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
./misc/legacy-nixpkgs-config.nix
./nixup/activation.nix
./nixup/build.nix
./nixup/nixup-tools.nix
./nixup/resource-files.nix
./nixup/switch-to-configuration.nix
./nixup/systemd.nix
Expand Down
53 changes: 53 additions & 0 deletions nixup/modules/nixup/nixup-tools.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{ config, lib, pkgs, ... }:

with lib;

let

cfg = config.nixup-tools;

managed-packages =
let
packagesString = if cfg.managed-packages-path == null
then let xdg_config_home_ = builtins.getEnv "XDG_CONFIG_HOME";
xdg_config_home = if xdg_config_home_ == "" then "${builtins.getEnv "HOME"}/.config" else xdg_config_home_;
in
if builtins.pathExists "${xdg_config_home}/nixup/packages.nix"
then readFile (builtins.toPath "${xdg_config_home}/nixup/packages.nix")
else ""
else if builtins.pathExists (builtins.toPath cfg.managed-packages-path)
then readFile (builtins.toPath cfg.managed-packages-path)
else "";
in
map (x : getAttr x pkgs) (remove "" (map (x: replaceChars ["\n"] [""] x) (splitString "\n" packagesString)));

in

{
options = {

nixup-tools = {
enable = mkOption {
default = false;
type = types.bool;
description = ''
Enable special tooling for NixUP.
'';
};
managed-packages-path = mkOption {
default = null;
type = types.nullOr types.path;
description = ''
Path of file to include into "user.packages".
"null" uses "$XDG_CONFIG_HOME/nixup/packages.nix".
'';
};
};
};

config = {

user.packages = mkIf cfg.enable ([ pkgs.nixup-tools ] ++ managed-packages);

};
}

0 comments on commit 3deede4

Please sign in to comment.