Compare commits
No commits in common. "748584c78e36ff823085c2186302132c2d94ac4d" and "45514d147cce57b2456a0e5142188a39bd2f69d0" have entirely different histories.
748584c78e
...
45514d147c
@ -2,6 +2,7 @@
|
|||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
home-manager,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -73,7 +74,6 @@
|
|||||||
./roles/zfs
|
./roles/zfs
|
||||||
./roles/zrepl
|
./roles/zrepl
|
||||||
./roles/zsh
|
./roles/zsh
|
||||||
./util/install_files
|
|
||||||
./util/unfree_polyfill
|
./util/unfree_polyfill
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -122,6 +122,21 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
users.groups.talexander.gid = 11235;
|
users.groups.talexander.gid = 11235;
|
||||||
|
home-manager.users.talexander =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
# The state version is required and should stay at the version you
|
||||||
|
# originally installed.
|
||||||
|
home.stateVersion = "24.11";
|
||||||
|
};
|
||||||
|
|
||||||
|
home-manager.users.root =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
# The state version is required and should stay at the version you
|
||||||
|
# originally installed.
|
||||||
|
home.stateVersion = "24.11";
|
||||||
|
};
|
||||||
|
|
||||||
# Automatic garbage collection
|
# Automatic garbage collection
|
||||||
nix.gc = lib.mkIf (!config.me.buildingIso) {
|
nix.gc = lib.mkIf (!config.me.buildingIso) {
|
||||||
|
21
nix/configuration/flake.lock
generated
21
nix/configuration/flake.lock
generated
@ -147,6 +147,26 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"home-manager": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1751549056,
|
||||||
|
"narHash": "sha256-miKaJ4SFNxhZ/WVDADae2jNd9zka5bV9hKmXspAzvxo=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"rev": "1fa73bb2cc39e250eb01e511ae6ac83bfbf9f38c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"impermanence": {
|
"impermanence": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1737831083,
|
"lastModified": 1737831083,
|
||||||
@ -283,6 +303,7 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"ansible-sshjail": "ansible-sshjail",
|
"ansible-sshjail": "ansible-sshjail",
|
||||||
"disko": "disko",
|
"disko": "disko",
|
||||||
|
"home-manager": "home-manager",
|
||||||
"impermanence": "impermanence",
|
"impermanence": "impermanence",
|
||||||
"lanzaboote": "lanzaboote",
|
"lanzaboote": "lanzaboote",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
nixpkgs-dda3dcd3f.url = "github:NixOS/nixpkgs/dda3dcd3fe03e991015e9a74b22d35950f264a54";
|
nixpkgs-dda3dcd3f.url = "github:NixOS/nixpkgs/dda3dcd3fe03e991015e9a74b22d35950f264a54";
|
||||||
nixpkgs-unoptimized.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs-unoptimized.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
home-manager.url = "github:nix-community/home-manager";
|
||||||
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
lanzaboote = {
|
lanzaboote = {
|
||||||
url = "github:nix-community/lanzaboote/v0.4.2";
|
url = "github:nix-community/lanzaboote/v0.4.2";
|
||||||
|
|
||||||
@ -76,6 +78,7 @@
|
|||||||
nixpkgs-unoptimized,
|
nixpkgs-unoptimized,
|
||||||
nixpkgs-dda3dcd3f,
|
nixpkgs-dda3dcd3f,
|
||||||
impermanence,
|
impermanence,
|
||||||
|
home-manager,
|
||||||
lanzaboote,
|
lanzaboote,
|
||||||
zsh-histdb,
|
zsh-histdb,
|
||||||
ansible-sshjail,
|
ansible-sshjail,
|
||||||
@ -96,8 +99,13 @@
|
|||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
impermanence.nixosModules.impermanence
|
impermanence.nixosModules.impermanence
|
||||||
|
home-manager.nixosModules.home-manager
|
||||||
lanzaboote.nixosModules.lanzaboote
|
lanzaboote.nixosModules.lanzaboote
|
||||||
inputs.disko.nixosModules.disko
|
inputs.disko.nixosModules.disko
|
||||||
|
{
|
||||||
|
home-manager.useGlobalPkgs = true;
|
||||||
|
home-manager.useUserPackages = true;
|
||||||
|
}
|
||||||
{
|
{
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
zsh-histdb.overlays.default
|
zsh-histdb.overlays.default
|
||||||
|
@ -24,11 +24,13 @@
|
|||||||
xdg-utils # for xdg-open
|
xdg-utils # for xdg-open
|
||||||
];
|
];
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".config/alacritty/alacritty.toml" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/alacritty.toml;
|
{
|
||||||
|
home.file.".config/alacritty/alacritty.toml" = {
|
||||||
|
source = ./files/alacritty.toml;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -141,12 +141,14 @@ in
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".config/emacs" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/emacs;
|
{
|
||||||
recursive = true;
|
home.file.".config/emacs" = {
|
||||||
|
source = ./files/emacs;
|
||||||
|
recursive = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
})
|
})
|
||||||
(lib.mkIf (config.me.emacs_flavor == "plainmacs") {
|
(lib.mkIf (config.me.emacs_flavor == "plainmacs") {
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
|
@ -36,11 +36,13 @@ in
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
(lib.mkIf (config.me.git.config != null) {
|
(lib.mkIf (config.me.git.config != null) {
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".gitconfig" = {
|
{ pkgs, ... }:
|
||||||
source = config.me.git.config;
|
{
|
||||||
|
home.file.".gitconfig" = {
|
||||||
|
source = config.me.git.config;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
})
|
})
|
||||||
(lib.mkIf (config.me.graphical) {
|
(lib.mkIf (config.me.graphical) {
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
|
@ -57,11 +57,14 @@ in
|
|||||||
# disable-ccid = true;
|
# disable-ccid = true;
|
||||||
# };
|
# };
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
# .gnupg/scdaemon.conf
|
||||||
".gnupg/scdaemon.conf" = {
|
home-manager.users.talexander =
|
||||||
source = ./files/scdaemon.conf;
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
home.file.".gnupg/scdaemon.conf" = {
|
||||||
|
source = ./files/scdaemon.conf;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
# programs.gnupg.dirmngr.enable = true;
|
# programs.gnupg.dirmngr.enable = true;
|
||||||
programs.gnupg.agent = {
|
programs.gnupg.agent = {
|
||||||
|
@ -41,11 +41,15 @@ in
|
|||||||
exec_kanshi
|
exec_kanshi
|
||||||
];
|
];
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".config/kanshi/config" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/config_kanshi;
|
{
|
||||||
|
home.file = {
|
||||||
|
".config/kanshi/config" = {
|
||||||
|
source = ./files/config_kanshi;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -78,13 +78,21 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# home.file.".kodi/userdata/mediasources.xml".source = ./files/mediasources.xml;
|
home-manager.users.kodi =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
# home.file.".kodi/userdata/mediasources.xml".source = ./files/mediasources.xml;
|
||||||
|
|
||||||
# home.file.".kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/DualSense_Wireless_Controller_13b_8a.xml".source =
|
# home.file.".kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/DualSense_Wireless_Controller_13b_8a.xml".source =
|
||||||
# ./files/DualSense_Wireless_Controller_13b_8a.xml;
|
# ./files/DualSense_Wireless_Controller_13b_8a.xml;
|
||||||
|
|
||||||
# TODO: Maybe .kodi/userdata/sources.xml
|
# TODO: Maybe .kodi/userdata/sources.xml
|
||||||
# TODO: ./userdata/guisettings.xml:303: <setting id="filecache.memorysize">128</setting>
|
# TODO: ./userdata/guisettings.xml:303: <setting id="filecache.memorysize">128</setting>
|
||||||
|
|
||||||
|
# The state version is required and should stay at the version you
|
||||||
|
# originally installed.
|
||||||
|
home.stateVersion = "24.11";
|
||||||
|
};
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -52,11 +52,13 @@ in
|
|||||||
imv
|
imv
|
||||||
];
|
];
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".config/mpv/mpv.conf" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/mpv.conf;
|
{
|
||||||
|
home.file.".config/mpv/mpv.conf" = {
|
||||||
|
source = ./files/mpv.conf;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
})
|
})
|
||||||
(lib.mkIf (config.me.graphics_card_type == "amd" || config.me.graphics_card_type == "intel") {
|
(lib.mkIf (config.me.graphics_card_type == "amd" || config.me.graphics_card_type == "intel") {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
@ -82,11 +82,13 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".config/PCSX2/inis/PCSX2.ini" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/PCSX2.ini;
|
{
|
||||||
|
home.file.".config/PCSX2/inis/PCSX2.ini" = {
|
||||||
|
source = ./files/PCSX2.ini;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -70,26 +70,28 @@ in
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".config/rpcs3/config.yml" = lib.mkIf (config.me.rpcs3.config != null) {
|
{ pkgs, ... }:
|
||||||
source = rpcs3_config_yaml;
|
{
|
||||||
|
home.file.".config/rpcs3/config.yml" = lib.mkIf (config.me.rpcs3.config != null) {
|
||||||
|
source = rpcs3_config_yaml;
|
||||||
|
};
|
||||||
|
home.file.".config/rpcs3/GuiConfigs/CurrentSettings.ini" = {
|
||||||
|
source = ./files/CurrentSettings.ini;
|
||||||
|
};
|
||||||
|
home.file.".config/rpcs3/custom_configs/config_BLUS30443.yml" = {
|
||||||
|
# Demon's Souls per-game config.
|
||||||
|
source = ./files/config_BLUS30443.yml;
|
||||||
|
};
|
||||||
|
home.file.".config/rpcs3/patches/patch.yml" = {
|
||||||
|
# All of the available patches.
|
||||||
|
source = ./files/patch.yml;
|
||||||
|
};
|
||||||
|
home.file.".config/rpcs3/patch_config.yml" = {
|
||||||
|
# Patches that I have enabled.
|
||||||
|
source = ./files/patch_config.yml;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
".config/rpcs3/GuiConfigs/CurrentSettings.ini" = {
|
|
||||||
source = ./files/CurrentSettings.ini;
|
|
||||||
};
|
|
||||||
".config/rpcs3/custom_configs/config_BLUS30443.yml" = {
|
|
||||||
# Demon's Souls per-game config.
|
|
||||||
source = ./files/config_BLUS30443.yml;
|
|
||||||
};
|
|
||||||
".config/rpcs3/patches/patch.yml" = {
|
|
||||||
# All of the available patches.
|
|
||||||
source = ./files/patch.yml;
|
|
||||||
};
|
|
||||||
".config/rpcs3/patch_config.yml" = {
|
|
||||||
# Patches that I have enabled.
|
|
||||||
source = ./files/patch_config.yml;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
|
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
|
||||||
hideMounts = true;
|
hideMounts = true;
|
||||||
|
@ -48,14 +48,18 @@ in
|
|||||||
# ? cargo-public-api
|
# ? cargo-public-api
|
||||||
];
|
];
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".cargo/config.toml" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/cargo_config.toml;
|
{
|
||||||
|
home.file = {
|
||||||
|
".cargo/config.toml" = {
|
||||||
|
source = ./files/cargo_config.toml;
|
||||||
|
};
|
||||||
|
".rustup/settings.toml" = {
|
||||||
|
source = ./files/rustup_settings.toml;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
".rustup/settings.toml" = {
|
|
||||||
source = ./files/rustup_settings.toml;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.persistence."/state" = lib.mkIf (!config.me.buildingIso) {
|
environment.persistence."/state" = lib.mkIf (!config.me.buildingIso) {
|
||||||
hideMounts = true;
|
hideMounts = true;
|
||||||
|
@ -24,11 +24,13 @@
|
|||||||
shadps4
|
shadps4
|
||||||
];
|
];
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".local/share/shadPS4/config.toml" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/config.toml;
|
{
|
||||||
|
home.file.".local/share/shadPS4/config.toml" = {
|
||||||
|
source = ./files/config.toml;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
|
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
|
||||||
hideMounts = true;
|
hideMounts = true;
|
||||||
|
@ -36,11 +36,15 @@ in
|
|||||||
exec_shikane
|
exec_shikane
|
||||||
];
|
];
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".config/shikane/config.toml" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/config.toml;
|
{
|
||||||
|
home.file = {
|
||||||
|
".config/shikane/config.toml" = {
|
||||||
|
source = ./files/config.toml;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -27,14 +27,19 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
me.install.user.root.file = {
|
home-manager.users.talexander =
|
||||||
".ssh/config" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/ssh_config_root;
|
{
|
||||||
|
home.file.".ssh/config" = {
|
||||||
|
source = ./files/ssh_config;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.root =
|
||||||
".ssh/config" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/ssh_config;
|
{
|
||||||
|
home.file.".ssh/config" = {
|
||||||
|
source = ./files/ssh_config_root;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -376,18 +376,26 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".config/mimeapps.list" = {
|
{ pkgs, ... }:
|
||||||
# Configure default programs (for example, default browser)
|
{
|
||||||
source = ./files/mimeapps.list;
|
home.file = {
|
||||||
|
# Configure default programs (for example, default browser)
|
||||||
|
".config/mimeapps.list" = {
|
||||||
|
source = ./files/mimeapps.list;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
home.file = {
|
||||||
|
".config/gtk-3.0/settings.ini" = {
|
||||||
|
source = ./files/settings.ini;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
home.file = {
|
||||||
|
".icons/default" = {
|
||||||
|
source = "${pkgs.adwaita-icon-theme}/share/icons/Adwaita";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
".config/gtk-3.0/settings.ini" = {
|
|
||||||
source = ./files/settings.ini;
|
|
||||||
};
|
|
||||||
".icons/default" = {
|
|
||||||
source = "${pkgs.adwaita-icon-theme}/share/icons/Adwaita";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# For mounting drives in pcmanfm
|
# For mounting drives in pcmanfm
|
||||||
services.gvfs.enable = true;
|
services.gvfs.enable = true;
|
||||||
|
@ -48,14 +48,16 @@
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".config/Code/User/settings.json" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/settings.json;
|
{
|
||||||
|
home.file.".config/Code/User/settings.json" = {
|
||||||
|
source = ./files/settings.json;
|
||||||
|
};
|
||||||
|
home.file.".config/Code/User/keybindings.json" = {
|
||||||
|
source = ./files/keybindings.json;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
".config/Code/User/keybindings.json" = {
|
|
||||||
source = ./files/keybindings.json;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -113,14 +113,18 @@ in
|
|||||||
|
|
||||||
services.upower.enable = true; # for battery
|
services.upower.enable = true; # for battery
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".config/waybar/config" = {
|
{ pkgs, ... }:
|
||||||
source = ./files/waybar_config.json;
|
{
|
||||||
|
home.file = {
|
||||||
|
".config/waybar/config" = {
|
||||||
|
source = ./files/waybar_config.json;
|
||||||
|
};
|
||||||
|
".config/waybar/style.css" = {
|
||||||
|
source = ./files/style.css;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
".config/waybar/style.css" = {
|
|
||||||
source = ./files/style.css;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -90,11 +90,13 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
home-manager.users.talexander =
|
||||||
".zshrc" = {
|
{ pkgs, ... }:
|
||||||
source = "${zshrc}";
|
{
|
||||||
|
home.file.".zshrc" = {
|
||||||
|
source = "${zshrc}";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
|
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
|
||||||
hideMounts = true;
|
hideMounts = true;
|
||||||
|
@ -1,333 +0,0 @@
|
|||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.me.install;
|
|
||||||
inherit (lib)
|
|
||||||
filter
|
|
||||||
attrNames
|
|
||||||
;
|
|
||||||
|
|
||||||
get_shell_values =
|
|
||||||
target:
|
|
||||||
let
|
|
||||||
homedir = config.users.users."${target.username}".home;
|
|
||||||
group = config.users.users."${target.username}".group;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
source = lib.strings.escapeShellArg "${target.source}";
|
|
||||||
destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
|
|
||||||
mode = lib.strings.escapeShellArg "${target.mode}";
|
|
||||||
dir_mode = lib.strings.escapeShellArg "${target.dir_mode}";
|
|
||||||
username = lib.strings.escapeShellArg "${target.username}";
|
|
||||||
group = lib.strings.escapeShellArg "${group}";
|
|
||||||
};
|
|
||||||
install_user_file =
|
|
||||||
let
|
|
||||||
constructors = {
|
|
||||||
"overwrite" = install_user_file_overwrite;
|
|
||||||
"symlink" = install_user_file_symlink;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
stage: target: (constructors."${target.method}"."${stage}" target);
|
|
||||||
install_user_file_overwrite = {
|
|
||||||
"check" = (target: "");
|
|
||||||
"install" = (
|
|
||||||
target:
|
|
||||||
let
|
|
||||||
inherit (get_shell_values target)
|
|
||||||
source
|
|
||||||
destination
|
|
||||||
mode
|
|
||||||
dir_mode
|
|
||||||
username
|
|
||||||
group
|
|
||||||
;
|
|
||||||
flags = lib.strings.concatStringsSep " " [
|
|
||||||
(if mode != "" then "-m ${mode}" else "")
|
|
||||||
(if username != "" then "-o ${username}" else "")
|
|
||||||
(if group != "" then "-g ${group}" else "")
|
|
||||||
];
|
|
||||||
dir_flags = lib.strings.concatStringsSep " " [
|
|
||||||
(if dir_mode != "" then "-m ${dir_mode}" else "")
|
|
||||||
(if username != "" then "-o ${username}" else "")
|
|
||||||
(if group != "" then "-g ${group}" else "")
|
|
||||||
];
|
|
||||||
in
|
|
||||||
if target.recursive then
|
|
||||||
[
|
|
||||||
''
|
|
||||||
find ${source} -type f -print0 | while read -r -d "" file; do
|
|
||||||
relative_path=$(realpath -s --relative-to ${source} "$file")
|
|
||||||
full_dest=${destination}/"$relative_path"
|
|
||||||
create_containing_directories "$full_dest" ${dir_flags}
|
|
||||||
$DRY_RUN_CMD install $VERBOSE_ARG --compare ${flags} "$file" "$full_dest"
|
|
||||||
done
|
|
||||||
''
|
|
||||||
]
|
|
||||||
else
|
|
||||||
[
|
|
||||||
''
|
|
||||||
create_containing_directories ${destination} ${dir_flags}
|
|
||||||
$DRY_RUN_CMD install $VERBOSE_ARG --compare ${flags} ${source} ${destination}
|
|
||||||
''
|
|
||||||
]
|
|
||||||
);
|
|
||||||
"uninstall" = (
|
|
||||||
target:
|
|
||||||
let
|
|
||||||
inherit (get_shell_values target)
|
|
||||||
source
|
|
||||||
destination
|
|
||||||
;
|
|
||||||
in
|
|
||||||
if target.recursive then
|
|
||||||
[
|
|
||||||
''
|
|
||||||
find ${source} -type f -print0 | while read -r -d "" file; do
|
|
||||||
relative_path=$(realpath -s --relative-to ${source} "$file")
|
|
||||||
full_dest=${destination}/"$relative_path"
|
|
||||||
$DRY_RUN_CMD echo rm -f "$full_dest"
|
|
||||||
done
|
|
||||||
''
|
|
||||||
]
|
|
||||||
else
|
|
||||||
[
|
|
||||||
''
|
|
||||||
$DRY_RUN_CMD echo rm -f ${destination}
|
|
||||||
''
|
|
||||||
]
|
|
||||||
);
|
|
||||||
};
|
|
||||||
install_user_file_symlink = {
|
|
||||||
"check" = (target: "");
|
|
||||||
"install" = (
|
|
||||||
target:
|
|
||||||
let
|
|
||||||
inherit (get_shell_values target)
|
|
||||||
source
|
|
||||||
destination
|
|
||||||
mode
|
|
||||||
dir_mode
|
|
||||||
username
|
|
||||||
group
|
|
||||||
;
|
|
||||||
owner = lib.strings.concatStringsSep ":" (
|
|
||||||
filter (val: val != "") [
|
|
||||||
username
|
|
||||||
group
|
|
||||||
]
|
|
||||||
);
|
|
||||||
dir_flags = lib.strings.concatStringsSep " " [
|
|
||||||
(if dir_mode != "" then "-m ${dir_mode}" else "")
|
|
||||||
(if username != "" then "-o ${username}" else "")
|
|
||||||
(if group != "" then "-g ${group}" else "")
|
|
||||||
];
|
|
||||||
in
|
|
||||||
if target.recursive then
|
|
||||||
[
|
|
||||||
''
|
|
||||||
find ${source} -type f -print0 | while read -r -d "" file; do
|
|
||||||
relative_path=$(realpath -s --relative-to ${source} "$file")
|
|
||||||
full_dest=${destination}/"$relative_path"
|
|
||||||
create_containing_directories "$full_dest" ${dir_flags}
|
|
||||||
$DRY_RUN_CMD ln $VERBOSE_ARG -s "$file" "$full_dest"
|
|
||||||
$DRY_RUN_CMD chown $VERBOSE_ARG -h ${owner} "$full_dest"
|
|
||||||
done
|
|
||||||
''
|
|
||||||
]
|
|
||||||
else
|
|
||||||
[
|
|
||||||
''
|
|
||||||
create_containing_directories ${destination} ${dir_flags}
|
|
||||||
$DRY_RUN_CMD ln $VERBOSE_ARG -s ${source} ${destination}
|
|
||||||
$DRY_RUN_CMD chown $VERBOSE_ARG -h ${owner} ${destination}
|
|
||||||
''
|
|
||||||
]
|
|
||||||
);
|
|
||||||
"uninstall" = (
|
|
||||||
target:
|
|
||||||
let
|
|
||||||
inherit (get_shell_values target)
|
|
||||||
source
|
|
||||||
destination
|
|
||||||
;
|
|
||||||
in
|
|
||||||
if target.recursive then
|
|
||||||
[
|
|
||||||
''
|
|
||||||
find ${source} -type f -print0 | while read -r -d "" file; do
|
|
||||||
relative_path=$(realpath -s --relative-to ${source} "$file")
|
|
||||||
full_dest=${destination}/"$relative_path"
|
|
||||||
$DRY_RUN_CMD echo rm -f "$full_dest"
|
|
||||||
done
|
|
||||||
''
|
|
||||||
]
|
|
||||||
else
|
|
||||||
[
|
|
||||||
''
|
|
||||||
$DRY_RUN_CMD echo rm -f ${destination}
|
|
||||||
''
|
|
||||||
]
|
|
||||||
);
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
imports = [ ];
|
|
||||||
|
|
||||||
options.me.install = {
|
|
||||||
user = lib.mkOption {
|
|
||||||
type = lib.types.attrsOf (
|
|
||||||
lib.types.submodule (
|
|
||||||
{ name, config, ... }:
|
|
||||||
let
|
|
||||||
username = name;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
enable = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
defaultText = "enable";
|
|
||||||
example = lib.literalExpression false;
|
|
||||||
description = "Whether we want to install files in this user's home directory.";
|
|
||||||
};
|
|
||||||
|
|
||||||
file = lib.mkOption {
|
|
||||||
type = lib.types.attrsOf (
|
|
||||||
lib.types.submodule (
|
|
||||||
{ name, config, ... }:
|
|
||||||
let
|
|
||||||
path = name;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
enable = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
defaultText = "enable";
|
|
||||||
example = lib.literalExpression false;
|
|
||||||
description = "Whether we want to install this file in this user's home directory.";
|
|
||||||
};
|
|
||||||
username = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
defaultText = "username";
|
|
||||||
example = "root";
|
|
||||||
description = "The username for the user whose home directory will contain the file.";
|
|
||||||
};
|
|
||||||
target = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
defaultText = "target";
|
|
||||||
example = ".local/share/foo/bar.txt";
|
|
||||||
description = "The path where the file should be written.";
|
|
||||||
};
|
|
||||||
method = lib.mkOption {
|
|
||||||
type = lib.types.enum [
|
|
||||||
"symlink"
|
|
||||||
"overwrite"
|
|
||||||
# "bind_mount" TODO: for directories?
|
|
||||||
];
|
|
||||||
default = "symlink";
|
|
||||||
defaultText = "me.install.file.‹path›.method";
|
|
||||||
example = "overwrite";
|
|
||||||
description = "The way in which the file should be installed.";
|
|
||||||
};
|
|
||||||
mode = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "0444";
|
|
||||||
defaultText = "me.install.file.‹path›.mode";
|
|
||||||
example = "0750";
|
|
||||||
description = "The read, write, execute permission flags.";
|
|
||||||
};
|
|
||||||
dir_mode = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "0755";
|
|
||||||
defaultText = "dir_mode";
|
|
||||||
example = "0755";
|
|
||||||
description = "The read, write, execute permission flags for any parent directories that need to be created.";
|
|
||||||
};
|
|
||||||
source = lib.mkOption {
|
|
||||||
type = lib.types.path;
|
|
||||||
defaultText = "me.install.file.‹path›.source";
|
|
||||||
example = ./files/foo.txt;
|
|
||||||
description = "The source file to install into the destination.";
|
|
||||||
};
|
|
||||||
recursive = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = false;
|
|
||||||
defaultText = "recursive";
|
|
||||||
example = lib.literalExpression false;
|
|
||||||
description = "Whether we want to recurse through the directory doing individual installs for each file.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
|
||||||
username = lib.mkDefault username;
|
|
||||||
target = lib.mkDefault path;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config =
|
|
||||||
let
|
|
||||||
all_users = builtins.map (username: cfg.user."${username}") (attrNames cfg.user);
|
|
||||||
enabled_users = filter (user: user.enable) all_users;
|
|
||||||
all_file_targets = lib.flatten (
|
|
||||||
builtins.map (user: (builtins.map (path: user.file."${path}") (attrNames user.file))) enabled_users
|
|
||||||
);
|
|
||||||
enabled_file_targets = filter (target: target.enable) all_file_targets;
|
|
||||||
check_commands = lib.flatten (builtins.map (install_user_file "check") enabled_file_targets);
|
|
||||||
install_commands = lib.flatten (builtins.map (install_user_file "install") enabled_file_targets);
|
|
||||||
uninstall_commands = lib.flatten (
|
|
||||||
builtins.map (install_user_file "uninstall") enabled_file_targets
|
|
||||||
);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
systemd.services.me-install-file = {
|
|
||||||
enable = true;
|
|
||||||
description = "me-install-file";
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
wants = [ "multi-user.target" ];
|
|
||||||
before = [ "multi-user.target" ];
|
|
||||||
# path = with pkgs; [
|
|
||||||
# zfs
|
|
||||||
# ];
|
|
||||||
unitConfig.DefaultDependencies = "no";
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = "yes";
|
|
||||||
};
|
|
||||||
script =
|
|
||||||
''
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
source ${./files/lib.bash}
|
|
||||||
''
|
|
||||||
+ (lib.strings.concatStringsSep "\n" (
|
|
||||||
[
|
|
||||||
]
|
|
||||||
++ check_commands
|
|
||||||
++ install_commands
|
|
||||||
));
|
|
||||||
preStop =
|
|
||||||
''
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
source ${./files/lib.bash}
|
|
||||||
''
|
|
||||||
+ (lib.strings.concatStringsSep "\n" uninstall_commands);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
|
|
||||||
############## Setup #########################
|
|
||||||
|
|
||||||
function die {
|
|
||||||
local status_code="$1"
|
|
||||||
shift
|
|
||||||
(>&2 echo "${@}")
|
|
||||||
exit "$status_code"
|
|
||||||
}
|
|
||||||
|
|
||||||
function log {
|
|
||||||
(>&2 echo "${@}")
|
|
||||||
}
|
|
||||||
|
|
||||||
############## Program #########################
|
|
||||||
|
|
||||||
function create_containing_directories {
|
|
||||||
local full_dest="$1"
|
|
||||||
shift 1
|
|
||||||
local dirs_to_create=()
|
|
||||||
local containing_directory="$full_dest"
|
|
||||||
while true; do
|
|
||||||
containing_directory=$(dirname "$containing_directory")
|
|
||||||
if [ -e "$containing_directory" ] || [ "$containing_directory" = "/" ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
dirs_to_create+=($containing_directory)
|
|
||||||
done
|
|
||||||
|
|
||||||
for (( idx=${#dirs_to_create[@]}-1 ; idx>=0 ; idx-- )) ; do
|
|
||||||
local containing_directory="${dirs_to_create[idx]}"
|
|
||||||
log "Creating $containing_directory"
|
|
||||||
$DRY_RUN_CMD install $VERBOSE_ARG -d "${@}" "$containing_directory"
|
|
||||||
done
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user