1
0
Fork 0

Update everything

This commit is contained in:
Malte Brandy 2019-08-02 05:17:00 +02:00
parent 51ac5d79b2
commit 351363b58f
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
78 changed files with 120 additions and 128 deletions

View file

@ -1,6 +1,6 @@
{ lib, pkgs, config, ... }:
let
inherit (import ../common/pkgs.nix) eventd;
inherit (import ../pkgs) eventd;
battery-watch = pkgs.writeScript "battery-watch" ''
#!${pkgs.stdenv.shell}

View file

@ -1,7 +1,8 @@
{ pkgs, config, ... }:
let
inherit (config.m-0.private) me meWork;
inherit (import ../common/pkgs.nix) lorri;
my-pkgs = import ../pkgs;
inherit (my-pkgs) lorri;
in {
imports = [
@ -139,7 +140,7 @@ in {
};
home = {
packages = builtins.attrValues (import ../common/pkgs.nix).home-pkgs;
packages = builtins.attrValues my-pkgs.home-pkgs;
sessionVariables = {
PATH =
"$HOME/.cargo/bin:/etc/profiles/per-user/${config.home.username}/bin:$HOME/.nix-profile/bin:$PATH";

View file

@ -1,7 +1,6 @@
{ pkgs, lib, config, ... }:
let inherit (import ../../common/pkgs.nix) desktop-pkgs;
let inherit (import ../../pkgs) desktop-pkgs;
in {
imports =
[ ./i3.nix ./rofi.nix ./ssh-agent.nix ./eventd.nix ./sleep-nag.nix ];
m-0 = {

View file

@ -1,7 +1,7 @@
{ pkgs, lib, config, ... }:
let
colors = config.m-0.colors;
inherit (import ../../common/pkgs.nix) eventd;
inherit (import ../../pkgs) eventd;
in {
home.packages = [ eventd ];

View file

@ -1,6 +1,6 @@
{ lib, pkgs, config, ... }:
let
inherit (import ../../common/pkgs.nix) eventd;
inherit (import ../../pkgs) eventd;
sleep-nag = pkgs.writeScript "sleep-nag" ''
#!${pkgs.stdenv.shell}

View file

@ -6,8 +6,7 @@ with lib; {
config = mkIf config.m-0.accounting.enable {
home.file.".config/jali/config.py".text = config.m-0.accounting.config;
home.packages =
builtins.attrValues (import ../../../common/pkgs.nix).accounting-pkgs;
home.packages = builtins.attrValues (import ../../../pkgs).accounting-pkgs;
};
}

View file

@ -1,11 +1,8 @@
{ pkgs, config, lib, ... }:
let
inherit (import ../common/lib.nix) writeHaskellScript;
sources = import ../nix/sources.nix;
let inherit (import ../lib) writeHaskellScript sources;
in {
home = {
packages =
builtins.attrValues (import ../common/pkgs.nix).foreign-home-pkgs;
packages = builtins.attrValues (import ../pkgs).foreign-home-pkgs;
sessionVariables = { NIX_PATH = "$HOME/.nix-path"; };
file = {
home-manager-source = {

View file

@ -2,6 +2,6 @@
home = {
username = "maralorn";
homeDirectory = "/home/maralorn";
packages = builtins.attrValues (import ../common/pkgs.nix).my-home-pkgs;
packages = builtins.attrValues (import ../pkgs).my-home-pkgs;
};
}

View file

@ -1,8 +1,7 @@
{ pkgs, config, lib, ... }:
let
inherit (import ../common/lib.nix)
writeHaskellScript get-niv-path gcRetentionDays;
inherit (import ./lib.nix) update-home;
inherit (import ../lib) writeHaskellScript get-niv-path gcRetentionDays;
inherit (import ../lib/update-home.nix) update-home;
configPath = "/home/${config.home.username}/git/nixos/config";
home-maintenance = writeHaskellScript {
name = "home-maintenance";

View file

@ -1,5 +1,5 @@
{ config, lib, pkgs, ... }:
let inherit (import ../common/pkgs.nix) eventd;
let inherit (import ../pkgs) eventd;
in {
systemd.user = {
services.update_tasks = {

View file

@ -3,8 +3,8 @@
# You need pw-files for every configured user in ./secret/pw-useralias for login to work.
let
inherit (config.m-0.private) me wireguard;
inherit (config.m-0) hosts prefix;
inherit (config.m-0) hosts prefix private;
inherit (private) me wireguard;
nixos-hardware = (import ../../nix/sources.nix).nixos-hardware;
in {
@ -15,7 +15,7 @@ in {
./hardware-configuration.nix
../../system
../../system/fonts.nix
../../system/standalone.nix
../../system/standalone
];
networking = {
@ -42,34 +42,6 @@ in {
m-0 = { laptop.enable = true; };
#let
#secretsFile = "/var/lib/luks-secret/key";
#secretsInitrd = "/boot/grub/secrets-initrd.gz";
#in
#{
#imports = [
#({lib, config, ...}: lib.mkIf (builtins.pathExists secretsFile) {
#boot.initrd.luks.devices."root" = {
#fallbackToPassword = true;
#keyFile = secretsFile;
#};
## copy the secret into the additional initramfs. `null` means same path
#boot.initrd.secrets."${secretsFile}" = null;
#})
#({lib, config, ...}: lib.mkIf (config.boot.loader.grub.enable && config.boot.initrd.secrets != {}) {
#boot.loader = {
#supportsInitrdSecrets = lib.mkForce true;
#grub.extraInitrd = secretsInitrd;
#grub.extraPrepareConfig = ''
#${config.system.build.initialRamdiskSecretAppender}/bin/append-initrd-secrets ${secretsInitrd}
#'';
#};
#})
#];
#}
# Use the systemd-boot EFI boot loader.
boot = {
loader = {

View file

@ -1,15 +1,14 @@
{ pkgs, config, ... }: {
imports = [
../../home-manager
../../home-manager/on-my-machine.nix
../../home-manager/battery.nix
../../home-manager/update_tasks.nix
../../home-manager/desktop
../../home
../../home/on-my-machine.nix
../../home/battery.nix
../../home/update_tasks.nix
../../home/desktop
];
home.packages =
builtins.attrValues (import ../../common/pkgs.nix).laptop-home-pkgs;
home.packages = builtins.attrValues (import ../../pkgs).laptop-home-pkgs;
m-0 = {
hostName = "apollo";

Binary file not shown.

View file

@ -1,19 +1,9 @@
{ pkgs, config, ... }: {
imports = [ ../../home-manager ../../home-manager/on-foreign-machine.nix ];
imports = [ ../../home ../../home/on-foreign-machine.nix ];
systemd.user.systemctlPath = "/usr/bin/systemctl";
m-0 = {
hostName = "fb04217";
#latex.enable = true;
#taskwarrior = {
# enable = true;
# git_active = true;
#};
#update_tasks.enable = true;
#eventd.enable = true;
#pythia.enable = true;
};
m-0 = { hostName = "fb04217"; };
home = {
username = "brandy";

View file

@ -10,8 +10,8 @@ in {
./hardware-configuration.nix
../../system
../../system/test-timer.nix
../../system/standalone.nix
../../system/server.nix
../../system/standalone
../../system/server
../../system/git.nix
./borg.nix
./mail.nix

View file

@ -1,7 +1,6 @@
{ pkgs, config, ... }: {
imports =
[ ../../home-manager ../../home-manager/on-my-machine.nix ./secret ];
imports = [ ../../home ../../home/on-my-machine.nix ./secret ];
m-0 = {
hostName = "hera";

View file

@ -2,7 +2,7 @@
let
hostName = "matrix.maralorn.de";
inherit (config.m-0) hosts;
inherit (../../common/lib.nix) unstable;
inherit (../../lib) unstable;
in {
networking.firewall.allowedTCPPorts = [ 3478 8448 ];

View file

@ -1,7 +1,8 @@
let
inherit (import ../common/pkgs.nix) niv;
inherit (import ../common/lib.nix)
inherit (import ../pkgs) niv;
inherit (import ../lib)
pkgs writeHaskellScript get-niv-path home-manager unstable haskellList;
in rec {
haskellBody = commandline: ''
getNivPath dir = readTrim . get_niv_path ([i|#{dir :: String}/nix/sources.nix|] :: String)
@ -34,13 +35,14 @@ let
systems = [ "apollo" "hera" ];
homes = [ "apollo" "hera" "hephaistos" ];
keys = [ "default" "apollo" "hera" ];
test-and-bump-config = writeHaskellScript {
name = "test-and-bump-config";
test-config = writeHaskellScript {
name = "test--config";
bins = [ test-system-config test-home-config pkgs.git niv pkgs.git-crypt ];
imports = [
"Control.Exception (bracket)"
"System.Directory (withCurrentDirectory)"
"Control.Monad (when)"
"Data.Maybe (listToMaybe)"
];
} ''
checkout :: IO FilePath
@ -51,12 +53,13 @@ let
main = do
path <- readTrim pwd
bump <- fmap ((== "bump") . listToMaybe) getArgs
bracket checkout (rm "-rf") $ \dir -> do
withCurrentDirectory dir $ do
mapM_ (\x -> git_crypt "unlock" ([i|${configPath}/.git/git-crypt/keys/#{x}|] :: String)) ${
haskellList keys
}
ignoreFailure $ niv "update"
when bump $ ignoreFailure $ niv "update"
mapM_ (test_system_config dir) ${haskellList systems}
mapM_ (test_home_config dir) ${haskellList homes}
changed <- ((mempty /=) <$>) . readTrim $ git "-C" dir "status" "--porcelain"
@ -66,4 +69,4 @@ let
git "-C" dir "commit" "-am" "Update dependencies with niv"
git "-C" dir "push"
'';
in { inherit test-system-config test-home-config test-and-bump-config; }
}

View file

@ -1,6 +1,4 @@
let
inherit (import ../common/lib.nix)
home-manager writeHaskellScript get-niv-path;
let inherit (import ./.) home-manager writeHaskellScript get-niv-path;
in {
update-home = configPath:
writeHaskellScript {

View file

@ -1,8 +1,8 @@
nixos-rebuild:
let
pkgs = import <nixpkgs> { };
inherit (import ../common/lib.nix)
writeHaskellScript get-niv-path home-manager gcRetentionDays;
inherit (import ../lib)
writeHaskellScript get-niv-path home-manager gcRetentionDays pkgs;
in rec {
configPath = "/etc/nixos";
update-system = writeHaskellScript {
name = "update-system";
@ -28,4 +28,4 @@ let
nix_collect_garbage "--delete-older-than" "${toString gcRetentionDays}d"
nix "optimise-store"
'';
in { inherit update-system system-maintenance; }
}

View file

@ -1,7 +1,8 @@
rec {
my-lib = import ../common/lib.nix;
let
my-lib = import ../lib;
inherit (my-lib) pkgs unstable sources writeHaskellScript;
tasktree = pkgs.callPackage ../packages/tasktree { };
in rec {
tasktree = pkgs.callPackage ./tasktree { };
neovim = pkgs.neovim.override {
vimAlias = true;
withPython3 = true;
@ -10,7 +11,7 @@ rec {
src = sources.lorri;
pkgs = unstable;
};
home-neovim = (import ../home-manager/nvim) neovim;
home-neovim = (import ./nvim) neovim;
niv = (import sources.niv { }).niv;
# pkgs assumed to be present on a non nixos host
@ -52,7 +53,7 @@ rec {
maintenance = pkgs.writeShellScriptBin "maintenance" ''
git -C ~/git/nixos/config pull
update-home
sudo system-maintenance
sudo -A system-maintenance
'';
rewlan = pkgs.writeShellScriptBin "rewlan" ''
nmcli r wifi off;
@ -153,15 +154,15 @@ rec {
inherit home-neovim;
};
accounting-pkgs = {
jali = pkgs.callPackage ../packages/jali { };
jali = pkgs.callPackage ./jali { };
inherit (pkgs.haskellPackages) hledger hledger-ui;
inherit (pkgs) ledger;
};
system-pkgs = core-system-pkgs // extra-system-pkgs // {
inherit (import ./test-lib.nix)
inherit (import ../lib/test.nix)
test-system-config test-home-config test-and-bump-config;
inherit (import ../common/lib.nix) home-manager;
inherit (my-lib) home-manager;
};
foreign-home-pkgs = extra-system-pkgs;
eventd = pkgs.callPackage ../packages/eventd { };
eventd = pkgs.callPackage ./eventd { };
}

View file

@ -8,7 +8,7 @@ n.override {
start = builtins.attrValues {
inherit ((import <nixpkgs> { }).vimPlugins)
vim-nix vimtex airline rust-vim fugitive vim-trailing-whitespace
vim-pandoc vim-pandoc-syntax haskell-vim vim-autoformat;
vim-pandoc vim-pandoc-syntax haskell-vim vim-autoformat vim-ledger;
};
};
};

View file

@ -49,3 +49,4 @@ let g:formatdef_my_nix = '"nixfmt"'
let g:formatters_nix = ['my_nix']
au BufWrite * :Autoformat
autocmd FileType ledger let b:autoformat_autoindent=0

1
result-home-manager-apollo Symbolic link
View file

@ -0,0 +1 @@
/nix/store/i6l690wqg4f3kghnmglzd0p9hmcpmjdy-home-manager-generation

View file

@ -0,0 +1 @@
/nix/store/l6dgwxmq4acp9dn6mfyfbjrdhg3nmznn-home-manager-generation

1
result-home-manager-hera Symbolic link
View file

@ -0,0 +1 @@
/nix/store/vpr0cppjsx0ycsyhypd180a6xdr6j1zz-home-manager-generation

1
result-system-apollo Symbolic link
View file

@ -0,0 +1 @@
/nix/store/q9aqkys4awwxjv2l1aq1v3vm3563qba8-nixos-system-apollo-19.03pre-git

1
result-system-hera Symbolic link
View file

@ -0,0 +1 @@
/nix/store/dj9jcdswgg3wr4irlbkn6q3lj48g4i5l-nixos-system-hera-19.03pre-git

View file

@ -1,6 +1,6 @@
{ pkgs, config, lib, ... }:
let
inherit (import ../common/lib.nix) sources;
inherit (import ../lib) sources;
me = config.m-0.private.me;
in {
imports = [
@ -47,6 +47,8 @@ in {
binaryCachePublicKeys =
[ "ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI=" ];
nixPath = [ "/etc/nix-path" ];
extraOptions = "fallback = true";
gc.options = "--delete-older-than 5d";
};
services = {

View file

@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }:
let
inherit (import ../common/lib.nix) writeHaskellScript haskellList;
inherit (import ../lib) writeHaskellScript haskellList;
me = config.m-0.private.me;
test-command =
[ "${pkgs.systemd}/bin/systemctl" "start" "test-and-bump-config.service" ];

View file

@ -1,23 +0,0 @@
{ config, pkgs, lib, ... }: {
imports = [ ./init_ssh.nix ];
config = {
systemd.services."system-maintenance" = {
startAt = "2:45";
environment.NIX_PATH =
"/etc/nix-path:nixos-config=/etc/nixos/configuration.nix";
path = [ pkgs.git ];
restartIfChanged = false;
unitConfig.X-StopOnRemoval = false;
serviceConfig = {
Type = "oneshot";
ExecStart = "${
(import ./update-lib.nix
config.system.build.nixos-rebuild).system-maintenance
}/bin/system-maintenance";
};
};
};
}

29
system/server/default.nix Normal file
View file

@ -0,0 +1,29 @@
{ config, pkgs, lib, ... }: {
imports = [ ./init_ssh.nix ];
systemd.services.test-and-update = {
startAt = "2:45";
environment.NIX_PATH =
"/etc/nix-path:nixos-config=/etc/nixos/configuration.nix";
path = [ pkgs.nix pkgs.gnutar pkgs.gzip pkgs.git pkgs.git-crypt ];
WorkingDirectory = "/var/cache/gc-links";
restartIfChanged = false;
unitConfig.X-StopOnRemoval = false;
serviceConfig = {
Type = "oneshot";
script = ''
${(import ../lib/test.nix).test-config}/bin/test-config
${
(import ../lib/update-system.nix
config.system.build.nixos-rebuild).update-system
}/bin/update-system
'';
};
};
nix = {
gc.automatic = true;
optimise.automatic = true;
};
}

View file

@ -0,0 +1,21 @@
{ lib, config, ... }:
let
secretsFile = "/var/lib/luks-secret/key";
secretsInitrd = "/boot/grub/secrets-initrd.gz";
in lib.mkIf (builtins.pathExists secretsFile) {
boot.initrd.luks.devices."root" = {
fallbackToPassword = true;
keyFile = secretsFile;
};
# copy the secret into the additional initramfs. `null` means same path
boot.initrd.secrets."${secretsFile}" = null;
} // lib.mkIf
(config.boot.loader.grub.enable && config.boot.initrd.secrets != { }) {
boot.loader = {
supportsInitrdSecrets = lib.mkForce true;
grub.extraInitrd = secretsInitrd;
grub.extraPrepareConfig = ''
${config.system.build.initialRamdiskSecretAppender}/bin/append-initrd-secrets ${secretsInitrd}
'';
};
}

View file

@ -1,7 +1,7 @@
{ pkgs, config, lib, ... }:
with lib; {
imports = [ ./admin.nix ];
imports = [ ./admin.nix ./boot-key.nix ];
# So that boot does not fill up with old kernels
boot.loader.grub.configurationLimit = 5;
@ -21,9 +21,10 @@ with lib; {
environment = {
# Put these into an extra file so the essential packages can also be included on non selfadminstrated systems from home-manager
systemPackages = builtins.attrValues ({
inherit (import ./update-lib.nix config.system.build.nixos-rebuild)
inherit (import ../../lib/update-system.nix
config.system.build.nixos-rebuild)
update-system system-maintenance;
} // (import ../common/pkgs.nix).system-pkgs);
} // (import ../../pkgs).system-pkgs);
sessionVariables = { TERMINFO = "/run/current-system/sw/share/terminfo"; };
};

View file

@ -5,9 +5,8 @@
serviceConfig = {
Type = "oneshot";
WorkingDirectory = "/var/cache/gc-links";
ExecStart = "${
(import ../common/test-lib.nix).test-and-bump-config
}/bin/test-and-bump-config";
ExecStart =
"${(import ../lib/test.nix).test-config}/bin/test-config bump";
};
};
}