-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.nix
86 lines (79 loc) · 2.78 KB
/
utils.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{ ... }:
rec {
listDir = dir: builtins.attrNames (builtins.readDir dir);
trimNixExts = configs: builtins.map (entry: builtins.substring 0 (builtins.stringLength entry - 4) entry) configs;
findNixFilesInDir = dir: trimNixExts (builtins.filter (u: (builtins.substring (builtins.stringLength u - 4) 4 u) == ".nix") (listDir dir));
generateUser =
{ name
, username
, email
, groups
, hosts
, face
, background
, files ? { }
, extraNixosConfig ? { }
, extraHomeConfig ? { }
, extraPackages ? [ ]
, pkgs
,
}: {
inherit hosts;
nixosConfig = {
isNormalUser = true;
description = name;
extraGroups = [ "networkmanager" "video" "audio" ] ++ groups;
shell = pkgs.zsh;
} // extraNixosConfig;
homeConfig = {
home.username = username;
home.homeDirectory = "/home/${username}";
home.packages = extraPackages;
programs.git.userName = name;
programs.git.userEmail = email;
home.file = {
".face".source = face;
} // files;
dconf.settings = {
"org/gnome/desktop/background" = {
"picture-uri" = "file://${background}";
"picture-uri-dark" = "file://${background}";
"color-shading-type" = "solid";
"picture-options" = "zoom";
"primary-color" = "#000000000000";
"secondary-color" = "#000000000000";
};
"org/gnome/desktop/screensaver" = {
"picture-uri" = "file://${background}";
"color-shading-type" = "solid";
"picture-options" = "zoom";
"primary-color" = "#000000000000";
"secondary-color" = "#000000000000";
};
};
} // extraHomeConfig;
};
# Allows unfree packages and insecure packages to be specified as
# `nixpkgs.allowUnfreePackages = [ "steam" "steam-original" ];`
# `nixpkgs.permittedInsecurePackages = [ "jitsi-meet" ];`
# Modified from code by @Majiir https://github.com/NixOS/nixpkgs/issues/197325#issuecomment-1579420085
nixpkgsMerger = { lib, config, ... }:
{
options = with lib; {
nixpkgs.allowUnfreePackages = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "steam" "steam-original" ];
};
nixpkgs.permittedInsecurePackages = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "jitsi-meet" ];
};
};
config = {
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.nixpkgs.allowUnfreePackages;
nixpkgs.config.allowInsecurePredicate = pkg: builtins.elem "${lib.getName pkg}-${lib.getVersion pkg}" config.nixpkgs.permittedInsecurePackages;
};
};
}