Compare commits
3 Commits
399379cea0
...
install_fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
504f8ecf09 | ||
|
|
7254bc8c7c | ||
|
|
a32f6bf0d1 |
@@ -8,7 +8,6 @@
|
||||
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
|
||||
bh = log --oneline --branches=* --remotes=* --graph --decorate
|
||||
amend = commit --amend --no-edit
|
||||
authorcount = shortlog --summary --numbered --all --no-merges
|
||||
[core]
|
||||
excludesfile = ~/.gitignore_global
|
||||
[commit]
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
|
||||
bh = log --oneline --branches=* --remotes=* --graph --decorate
|
||||
amend = commit --amend --no-edit
|
||||
authorcount = shortlog --summary --numbered --all --no-merges
|
||||
[core]
|
||||
excludesfile = ~/.gitignore_global
|
||||
[commit]
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
./roles/reset
|
||||
./roles/rpcs3
|
||||
./roles/rust
|
||||
./roles/shadps4
|
||||
./roles/shikane
|
||||
./roles/shipwright
|
||||
./roles/sm64ex
|
||||
@@ -73,9 +72,14 @@
|
||||
./roles/zfs
|
||||
./roles/zrepl
|
||||
./roles/zsh
|
||||
./util/install_files
|
||||
./util/unfree_polyfill
|
||||
];
|
||||
|
||||
me.install.user.talexander.file."/home/talexander/flake.nix" = {
|
||||
source = ./flake.nix;
|
||||
};
|
||||
|
||||
nix.settings.experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
@@ -141,9 +145,7 @@
|
||||
nix.gc = lib.mkIf (!config.me.buildingIso) {
|
||||
# Runs nix-collect-garbage --delete-older-than 5d
|
||||
automatic = true;
|
||||
persistent = true;
|
||||
dates = "weekly";
|
||||
# randomizedDelaySec = "14m";
|
||||
randomizedDelaySec = "14m";
|
||||
options = "--delete-older-than 30d";
|
||||
};
|
||||
nix.settings.auto-optimise-store = !config.me.buildingIso;
|
||||
@@ -172,7 +174,7 @@
|
||||
pciutils # for lspci
|
||||
ripgrep
|
||||
strace
|
||||
# ltrace # Disabled because it uses more than 48GB of /tmp space during test phase.
|
||||
ltrace
|
||||
trace-cmd # ftrace
|
||||
tcpdump
|
||||
git-crypt
|
||||
|
||||
54
nix/configuration/flake.lock
generated
54
nix/configuration/flake.lock
generated
@@ -39,11 +39,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1750903843,
|
||||
"narHash": "sha256-Ng9+f0H5/dW+mq/XOKvB9uwvGbsuiiO6HrPdAcVglCs=",
|
||||
"lastModified": 1746729224,
|
||||
"narHash": "sha256-9R4sOLAK1w3Bq54H3XOJogdc7a6C2bLLmatOQ+5pf5w=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "83c4da299c1d7d300f8c6fd3a72ac46cb0d59aae",
|
||||
"rev": "85555d27ded84604ad6657ecca255a03fd878607",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -154,11 +154,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1751549056,
|
||||
"narHash": "sha256-miKaJ4SFNxhZ/WVDADae2jNd9zka5bV9hKmXspAzvxo=",
|
||||
"lastModified": 1746981801,
|
||||
"narHash": "sha256-+Bfr0KqZV6gZdA7e2kupeoawozaLIHLuiPtC54uxbFc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "1fa73bb2cc39e250eb01e511ae6ac83bfbf9f38c",
|
||||
"rev": "ff915842e4a2e63c4c8c5c08c6870b9d5b3c3ee9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -209,22 +209,6 @@
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1751271578,
|
||||
"narHash": "sha256-P/SQmKDu06x8yv7i0s8bvnnuJYkxVGBWLWHaU+tt4YY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3016b4b15d13f3089db8a41ef937b13a9e33a8df",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-dda3dcd3f": {
|
||||
"locked": {
|
||||
"lastModified": 1746663147,
|
||||
"narHash": "sha256-Ua0drDHawlzNqJnclTJGf87dBmaO/tn7iZ+TCkTRpRc=",
|
||||
@@ -235,8 +219,24 @@
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "dda3dcd3fe03e991015e9a74b22d35950f264a54",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-b93b4e9b5": {
|
||||
"locked": {
|
||||
"lastModified": 1713721570,
|
||||
"narHash": "sha256-R0s+O5UjTePQRb72XPgtkTmEiOOW8n+1q9Gxt/OJnKU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b93b4e9b527904aadf52dba6ca35efde2067cbd4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b93b4e9b527904aadf52dba6ca35efde2067cbd4",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
@@ -258,11 +258,11 @@
|
||||
},
|
||||
"nixpkgs-unoptimized": {
|
||||
"locked": {
|
||||
"lastModified": 1751271578,
|
||||
"narHash": "sha256-P/SQmKDu06x8yv7i0s8bvnnuJYkxVGBWLWHaU+tt4YY=",
|
||||
"lastModified": 1746663147,
|
||||
"narHash": "sha256-Ua0drDHawlzNqJnclTJGf87dBmaO/tn7iZ+TCkTRpRc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3016b4b15d13f3089db8a41ef937b13a9e33a8df",
|
||||
"rev": "dda3dcd3fe03e991015e9a74b22d35950f264a54",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -307,7 +307,7 @@
|
||||
"impermanence": "impermanence",
|
||||
"lanzaboote": "lanzaboote",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-dda3dcd3f": "nixpkgs-dda3dcd3f",
|
||||
"nixpkgs-b93b4e9b5": "nixpkgs-b93b4e9b5",
|
||||
"nixpkgs-unoptimized": "nixpkgs-unoptimized",
|
||||
"zsh-histdb": "zsh-histdb"
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
inputs = {
|
||||
impermanence.url = "github:nix-community/impermanence";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
nixpkgs-dda3dcd3f.url = "github:NixOS/nixpkgs/dda3dcd3fe03e991015e9a74b22d35950f264a54";
|
||||
nixpkgs-b93b4e9b5.url = "github:NixOS/nixpkgs/b93b4e9b527904aadf52dba6ca35efde2067cbd4";
|
||||
nixpkgs-unoptimized.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
home-manager.url = "github:nix-community/home-manager";
|
||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||
@@ -76,7 +76,7 @@
|
||||
self,
|
||||
nixpkgs,
|
||||
nixpkgs-unoptimized,
|
||||
nixpkgs-dda3dcd3f,
|
||||
nixpkgs-b93b4e9b5,
|
||||
impermanence,
|
||||
home-manager,
|
||||
lanzaboote,
|
||||
@@ -88,7 +88,7 @@
|
||||
base_x86_64_linux = rec {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = {
|
||||
pkgs-dda3dcd3f = import nixpkgs-dda3dcd3f {
|
||||
pkgs-b93b4e9b5 = import nixpkgs-b93b4e9b5 {
|
||||
inherit system;
|
||||
};
|
||||
pkgs-unoptimized = import nixpkgs-unoptimized {
|
||||
|
||||
@@ -88,7 +88,6 @@
|
||||
me.qemu.enable = true;
|
||||
me.rpcs3.enable = true;
|
||||
me.rust.enable = true;
|
||||
me.shadps4.enable = true;
|
||||
me.shikane.enable = true;
|
||||
me.sops.enable = true;
|
||||
me.sound.enable = true;
|
||||
|
||||
@@ -84,7 +84,6 @@
|
||||
me.qemu.enable = true;
|
||||
me.rpcs3.enable = true;
|
||||
me.rust.enable = true;
|
||||
me.shadps4.enable = true;
|
||||
me.shikane.enable = true;
|
||||
me.sops.enable = true;
|
||||
me.sound.enable = true;
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
(when rust-analyzer-command
|
||||
;; (add-to-list 'eglot-server-programs `(rust-ts-mode . (,rust-analyzer-command)))
|
||||
(add-to-list 'eglot-server-programs `(rust-ts-mode . (,rust-analyzer-command :initializationOptions (:imports (:granularity (:enforce t :group "item")
|
||||
:merge (:glob :json-false)
|
||||
:merge (:glob nil)
|
||||
:prefix "self")
|
||||
))))
|
||||
)
|
||||
|
||||
@@ -8,14 +8,10 @@
|
||||
{
|
||||
imports = [ ];
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
memtest86plus
|
||||
];
|
||||
}
|
||||
# (lib.mkIf (config.me.buildingIso) {
|
||||
# boot.loader.systemd-boot.memtest86.enable = true;
|
||||
# boot.loader.grub.memtest86.enable = true;
|
||||
# })
|
||||
{ }
|
||||
(lib.mkIf (config.me.buildingIso) {
|
||||
# boot.loader.systemd-boot.memtest86.enable = true;
|
||||
boot.loader.grub.memtest86.enable = true;
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
pkgs-dda3dcd3f,
|
||||
...
|
||||
}:
|
||||
|
||||
@@ -65,7 +64,6 @@
|
||||
ldns # for drill
|
||||
arp-scan # To find devices on the network
|
||||
wavemon
|
||||
dhcpcd # For Android USB tethering.
|
||||
];
|
||||
|
||||
boot.extraModprobeConfig = ''
|
||||
@@ -93,13 +91,4 @@
|
||||
# This is enabled by default in nixos.
|
||||
# "net.ipv6.conf.default.use_tempaddr" = 2;
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(final: prev: {
|
||||
inherit (pkgs-dda3dcd3f)
|
||||
linux-firmware
|
||||
;
|
||||
})
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
(lib.mkIf (!config.me.optimizations.enable) (
|
||||
lib.mkMerge [
|
||||
{
|
||||
boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_6_15;
|
||||
boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_6_14;
|
||||
}
|
||||
]
|
||||
))
|
||||
@@ -94,7 +94,7 @@
|
||||
HZ = lib.kernel.freeform "300";
|
||||
HZ_300 = lib.kernel.yes;
|
||||
HZ_1000 = lib.kernel.no;
|
||||
} prev.linux_6_15;
|
||||
} prev.linux_6_14;
|
||||
}
|
||||
)
|
||||
(final: prev: {
|
||||
@@ -132,7 +132,6 @@
|
||||
redis
|
||||
valkey
|
||||
nix-serve-ng
|
||||
rapidjson
|
||||
;
|
||||
})
|
||||
];
|
||||
|
||||
@@ -79,18 +79,6 @@ in
|
||||
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;
|
||||
};
|
||||
};
|
||||
|
||||
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
|
||||
@@ -158,13 +146,6 @@ in
|
||||
mode = "0755";
|
||||
};
|
||||
}
|
||||
{
|
||||
# Netplay (RPCN) config and credentials
|
||||
file = ".config/rpcs3/rpcn.yml";
|
||||
parentDirectory = {
|
||||
mode = "0755";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
@@ -174,6 +155,7 @@ in
|
||||
users.talexander = {
|
||||
directories = [
|
||||
{
|
||||
# Game saves
|
||||
directory = ".cache/rpcs3";
|
||||
user = "talexander";
|
||||
group = "talexander";
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
Core:
|
||||
SPU Block Size: Safe
|
||||
Video:
|
||||
Write Color Buffers: true
|
||||
Minimum Scalable Dimension: 640
|
||||
Net:
|
||||
Internet enabled: Connected
|
||||
IP address: 0.0.0.0
|
||||
Bind address: 0.0.0.0
|
||||
DNS address: 8.8.8.8
|
||||
IP swap list: "ds-eu-c.scej-online.jp=206.189.232.242&&ds-eu-g.scej-online.jp=206.189.232.242&&c.demons-souls.com=206.189.232.242&&g.demons-souls.com=206.189.232.242&&cmnap.scej-online.jp=206.189.232.242&&demons-souls.scej-online.jp=206.189.232.242"
|
||||
UPNP Enabled: false
|
||||
PSN status: RPCN
|
||||
PSN Country: us
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +0,0 @@
|
||||
PPU-83681f6110d33442329073b72b8dc88a2f677172:
|
||||
Unlock FPS:
|
||||
Demon's Souls:
|
||||
BLUS30443:
|
||||
01.00:
|
||||
Enabled: true
|
||||
@@ -1,12 +1,12 @@
|
||||
# [target.x86_64-unknown-linux-gnu]
|
||||
# rustflags = ["-C", "target-cpu=native", "-Zthreads=0"]
|
||||
[target.x86_64-unknown-linux-gnu]
|
||||
rustflags = ["-C", "target-cpu=native", "-Zthreads=0"]
|
||||
|
||||
# [unstable]
|
||||
# codegen-backend = true
|
||||
[unstable]
|
||||
codegen-backend = true
|
||||
|
||||
# [profile.dev]
|
||||
# codegen-backend = "cranelift"
|
||||
[profile.dev]
|
||||
codegen-backend = "cranelift"
|
||||
|
||||
[profile.dev.package."*"]
|
||||
# codegen-backend = "llvm"
|
||||
codegen-backend = "llvm"
|
||||
opt-level = 3
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [ ];
|
||||
|
||||
options.me = {
|
||||
shadps4.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "Whether we want to install shadps4.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.me.shadps4.enable (
|
||||
lib.mkMerge [
|
||||
(lib.mkIf config.me.graphical {
|
||||
environment.systemPackages = with pkgs; [
|
||||
shadps4
|
||||
];
|
||||
|
||||
home-manager.users.talexander =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home.file.".local/share/shadPS4/config.toml" = {
|
||||
source = ./files/config.toml;
|
||||
};
|
||||
};
|
||||
|
||||
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
|
||||
hideMounts = true;
|
||||
users.talexander = {
|
||||
directories = [
|
||||
{
|
||||
# Location of ROMs.
|
||||
directory = ".local/share/shadPS4/games";
|
||||
user = "talexander";
|
||||
group = "talexander";
|
||||
mode = "0755";
|
||||
}
|
||||
{
|
||||
# Firmware.
|
||||
directory = ".local/share/shadPS4/sys_modules";
|
||||
user = "talexander";
|
||||
group = "talexander";
|
||||
mode = "0755";
|
||||
}
|
||||
{
|
||||
# Game saves.
|
||||
directory = ".local/share/shadPS4/savedata";
|
||||
user = "talexander";
|
||||
group = "talexander";
|
||||
mode = "0755";
|
||||
}
|
||||
{
|
||||
# DLC.
|
||||
directory = ".local/share/shadPS4/addcont";
|
||||
user = "talexander";
|
||||
group = "talexander";
|
||||
mode = "0755";
|
||||
}
|
||||
];
|
||||
files = [
|
||||
{
|
||||
# play times and recently played
|
||||
file = ".local/share/shadPS4/play_time.txt";
|
||||
parentDirectory = {
|
||||
mode = "0755";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
environment.persistence."/state" = lib.mkIf (!config.me.buildingIso) {
|
||||
hideMounts = true;
|
||||
users.talexander = {
|
||||
directories = [
|
||||
{
|
||||
# Cache.
|
||||
directory = ".local/share/shadPS4/data";
|
||||
user = "talexander";
|
||||
group = "talexander";
|
||||
mode = "0755";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(final: prev: {
|
||||
shadps4 = prev.shadps4.overrideAttrs (old: {
|
||||
version = "0.9.0";
|
||||
src = final.fetchFromGitHub {
|
||||
owner = "AzaharPlus";
|
||||
repo = "shadPS4Plus";
|
||||
tag = "SHADPS4PLUS_0_9_0_A";
|
||||
hash = "sha256-ZwP+bOE4roWt51Ii53blDZzdq/SxK4Q69I4rLCNARLA=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
});
|
||||
})
|
||||
];
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
[General]
|
||||
# Without this, we get:
|
||||
# /run/current-system/sw/bin/xdg-mime: line 1002: /nix/store/wd9bigydk9x8bsvnslrvb5klbgmh98v5-hm_mimeapps.list.new: Read-only file system
|
||||
enableDiscordRPC = false
|
||||
|
||||
|
||||
[GUI]
|
||||
addonInstallDir = "/home/talexander/.local/share/shadPS4/addcont"
|
||||
installDirs = ["/home/talexander/.local/share/shadPS4/games"]
|
||||
installDirsEnabled = [true]
|
||||
# Without the geometry settings shadps4 crashes instantly with a floating point error.
|
||||
geometry_h = 981
|
||||
geometry_w = 748
|
||||
geometry_x = 0
|
||||
geometry_y = 0
|
||||
179
nix/configuration/util/install_files/default.nix
Normal file
179
nix/configuration/util/install_files/default.nix
Normal file
@@ -0,0 +1,179 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
home-manager,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
attrNames
|
||||
filter
|
||||
flatten
|
||||
;
|
||||
makeFileOption =
|
||||
prefix:
|
||||
lib.mkOption {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule (
|
||||
{ name, config, ... }:
|
||||
{
|
||||
options = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
defaultText = "${prefix}.‹path›.enable";
|
||||
example = false;
|
||||
description = "Whether we want to install this file.";
|
||||
};
|
||||
method = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"symlink"
|
||||
"overwrite"
|
||||
"initialize"
|
||||
# "bind_mount" TODO: for directories?
|
||||
];
|
||||
default = "symlink";
|
||||
defaultText = "${prefix}.‹path›.method";
|
||||
example = "overwrite";
|
||||
description = "The way in which the file should be installed.";
|
||||
};
|
||||
mode = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "0444";
|
||||
defaultText = "${prefix}.‹path›.mode";
|
||||
example = "0750";
|
||||
description = "The read, write, execute permission flags.";
|
||||
};
|
||||
source = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
defaultText = "${prefix}.‹path›.source";
|
||||
example = ./files/foo.txt;
|
||||
description = "The source file to install into the destination.";
|
||||
};
|
||||
target = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
defaultText = "${prefix}.‹path›.target";
|
||||
example = ".local/share/foo/bar.txt";
|
||||
description = "The path where the file should be written.";
|
||||
};
|
||||
group = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
defaultText = "${prefix}.‹path›.group";
|
||||
example = ".local/share/foo/bar.txt";
|
||||
description = "The group that should own the file.";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
target = lib.mkDefault name;
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
defaultText = "${prefix}.‹path›";
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
".config/foo/bar.txt" = {
|
||||
source = ./files/bar.txt
|
||||
};
|
||||
}
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
|
||||
options.me.install = {
|
||||
user = lib.mkOption {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule (
|
||||
{ name, config, ... }:
|
||||
{
|
||||
options = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
defaultText = "me.install.user.‹username›.enable";
|
||||
example = false;
|
||||
description = "Whether we want to install files in this user's home directory.";
|
||||
};
|
||||
target_username = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
defaultText = "me.install.file.‹username›.target_username";
|
||||
example = "root";
|
||||
description = "The username for the user whose home directory will contain the file.";
|
||||
};
|
||||
file = makeFileOption "me.install.user.‹username›.file";
|
||||
};
|
||||
|
||||
config = {
|
||||
target_username = lib.mkDefault name;
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
defaultText = "me.install.user.‹username›";
|
||||
default = { };
|
||||
# TODO: example
|
||||
};
|
||||
# TODO: Global option owned by root?
|
||||
# file = makeFileOption "me.install.file";
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
cfg = config.me.install;
|
||||
active_install_users = filter (username: cfg.user."${username}".enable) (attrNames cfg.user);
|
||||
install_commands = flatten (
|
||||
builtins.map (
|
||||
username:
|
||||
let
|
||||
active_install_file_targets = filter (target: cfg.user."${username}".file."${target}".enable) (
|
||||
attrNames cfg.user."${username}".file
|
||||
);
|
||||
in
|
||||
builtins.map (
|
||||
target:
|
||||
let
|
||||
target_config = cfg.user."${username}".file."${target}";
|
||||
source = lib.strings.escapeShellArg "${target_config.source}";
|
||||
destination = lib.strings.escapeShellArg "${target_config.target}";
|
||||
mode = lib.strings.escapeShellArg "${target_config.mode}";
|
||||
escaped_username = lib.strings.escapeShellArg "${username}";
|
||||
escaped_group =
|
||||
if target_config.group == null then
|
||||
"$(id -g ${escaped_username})"
|
||||
else
|
||||
(lib.strings.escapeShellArg "${target_config.group}");
|
||||
in
|
||||
''
|
||||
$DRY_RUN_CMD install $VERBOSE_ARG -D --compare -o ${escaped_username} -g ${escaped_group} -m ${mode} ${source} ${destination}
|
||||
''
|
||||
) active_install_file_targets
|
||||
) active_install_users
|
||||
);
|
||||
|
||||
in
|
||||
lib.mkMerge [
|
||||
(lib.mkIf (install_commands != [ ]) ({
|
||||
systemd.services.me-install-file = {
|
||||
enable = true;
|
||||
description = "me-install-file";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "multi-user.target" ];
|
||||
after = [ "multi-user.target" ];
|
||||
unitConfig.DefaultDependencies = "no";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = "yes";
|
||||
};
|
||||
script = (lib.strings.concatStringsSep "\n" install_commands);
|
||||
};
|
||||
}))
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user