-
-
Save aszlig/61cb3307daf2e1aa2457a1ea778618a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs/lib>; | |
let | |
vuizvuiUrl = "https://github.com/openlab-aux/vuizvui/archive/master.tar.gz"; | |
vuizvui = fetchTarball vuizvuiUrl; | |
vimModule = import "${vuizvui}/modules/user/aszlig/programs/vim/default.nix"; | |
eval = import <nixpkgs/nixos/lib/eval-config.nix> { | |
modules = singleton vimModule ++ singleton ({ pkgs, config, lib, ... }: { | |
vuizvui.user.aszlig.programs.vim.enable = true; | |
nix = { | |
package = pkgs.nixUnstable; | |
maxJobs = 8; | |
buildCores = 0; | |
nrBuildUsers = 100; | |
useSandbox = true; | |
trustedUsers = [ "hydrabuild" ]; | |
}; | |
nix.gc = { | |
automatic = true; | |
dates = "0/6:0"; | |
options = let | |
minSpace = 200; | |
avail = "$(df -k -BG --output=avail /nix/store " | |
+ "| sed -ne '$s/[^0-9]//gp')"; | |
maxFreed = "${toString minSpace} - ${avail}"; | |
in "--max-freed \"$(((${maxFreed}) * 1024 ** 3))\""; | |
}; | |
system.build.nix-units = let | |
sysWants = [ | |
"sockets.target.wants" | |
"multi-user.target.wants" | |
"timers.target.wants" | |
]; | |
sysUnits = [ | |
"sockets.target" | |
"timers.target" | |
] ++ config.systemd.additionalUpstreamSystemUnits; | |
inherit (import <nixpkgs/nixos/modules/system/boot/systemd-lib.nix> { | |
inherit config lib pkgs; | |
}) generateUnits; | |
toFilter = [ | |
"nix-daemon." | |
"nix-gc." | |
]; | |
filteredUnits = with lib; let | |
filterNix = name: const (any (what: hasPrefix what name) toFilter); | |
in filterAttrs filterNix config.system.build.units; | |
generated = generateUnits "system" filteredUnits sysUnits sysWants; | |
in pkgs.runCommand "nix-daemon-units" { | |
inherit generated; | |
} '' | |
mkdir -p "$out" | |
${lib.concatMapStrings (what: '' | |
cp -Lr "${generated}/${what}"* "$out/" | |
'') toFilter} | |
''; | |
}); | |
}; | |
vim = let | |
findVim = filter (drv: hasPrefix "vim_configurable-" drv.name); | |
in head (findVim eval.config.environment.systemPackages); | |
nix = eval.config.nix.package.out; | |
nixConf = eval.config.environment.etc."nix/nix.conf".source; | |
pkgs = import <nixpkgs> {}; | |
bashrc = pkgs.writeTextFile { | |
name = "nix.bashrc"; | |
destination = "/etc/nix.bashrc"; | |
text = '' | |
source "${nix}/etc/profile.d/nix.sh" | |
export NIX_PATH=nixpkgs=/root/nixpkgs | |
export NIX_REMOTE=daemon | |
''; | |
}; | |
in pkgs.writeScript "activate.sh" '' | |
#!${pkgs.stdenv.shell} -e | |
mkdir -p /etc/nix | |
ln -sfT "${nixConf}" /etc/nix/nix.conf | |
for i in "${eval.config.system.build.nix-units}"/*; do | |
rm -rf "/etc/systemd/system/$(basename "$i")" | |
cp -rL "$i" "/etc/systemd/system/$(basename "$i")" | |
done | |
systemctl reenable nix-daemon.socket nix-gc.timer | |
systemctl daemon-reload | |
systemctl restart nix-daemon.service nix-daemon.socket | |
"${nix}/bin/nix-env" -i "${vim}" "${nix}" "${bashrc}" | |
'' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment