1
0
Fork 0

Improve update-timer

This commit is contained in:
Malte Brandy 2019-08-02 19:04:31 +02:00
parent 2a2c5369bb
commit 35c73a4f8f
4 changed files with 52 additions and 46 deletions

View file

@ -1,7 +1,7 @@
let
inherit (import ../pkgs) niv;
inherit (import ../lib)
pkgs writeHaskellScript get-niv-path home-manager unstable haskellList;
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)
@ -55,7 +55,7 @@ in rec {
bracket checkout (rm "-rf") $ \dir -> do
withCurrentDirectory dir $ do
mapM_ (\x -> git_crypt "unlock" ([i|${configPath}/.git/git-crypt/keys/#{x}|] :: String)) ${
haskellList keys
haskellList keys
}
when bump $ ignoreFailure $ niv "update"
mapM_ (test_system_config dir) ${haskellList systems}

View file

@ -39,14 +39,14 @@ in rec {
} ''
waitForExit = do
sleep "5s"
processes <- readTrim $ ps "aux"
when
(BSC.isInfixOf (BSC.pack "GW2.exe") (LBSC.toStrict processes))
waitForExit
main = do
withCurrentDirectory "/home/maralorn/GW2" $ exe "./play.sh"
sleep "5s"
processes <- readTrim $ ps "aux"
when
(BSC.isInfixOf (BSC.pack "GW2.exe") (LBSC.toStrict processes))
waitForExit
main = do
withCurrentDirectory "/home/maralorn/GW2" $ exe "./play.sh"
waitForExit
'';
laptop-home-pkgs = {
@ -140,11 +140,11 @@ in rec {
};
urxvt = pkgs.rxvt_unicode-with-plugins;
terminal = pkgs.writeShellScriptBin "terminal" ''
${urxvt}/bin/urxvtc "$@"
if [ $? -eq 2 ]; then
${urxvt}/bin/urxvtd -q -o -f
${urxvt}/bin/urxvtc "$@"
fi
if [ $? -eq 2 ]; then
${urxvt}/bin/urxvtd -q -o -f
${urxvt}/bin/urxvtc "$@"
fi
'';
desktop-pkgs = {
inherit urxvt tasktree terminal;

View file

@ -1,30 +1,7 @@
{ config, pkgs, lib, ... }:
let user = "maralorn";
in {
{ 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 ];
restartIfChanged = false;
unitConfig.X-StopOnRemoval = false;
serviceConfig = {
Type = "oneshot";
WorkingDirectory = "/var/cache/gc-links";
};
script = ''
${(import ../../lib/test.nix).test-config}/bin/test-config
/run/wrappers/bin/sudo -u ${user} git -C /etc/nixos pull
${
(import ../../lib/update-system.nix
config.system.build.nixos-rebuild).update-system
}/bin/update-system
/run/wrappers/bin/sudo -u ${user} update-home
'';
};
nix = {
gc.automatic = true;
optimise.automatic = true;

View file

@ -1,12 +1,41 @@
{ pkgs, config, lib, ... }: {
systemd.services."test-and-bump-config" = {
startAt = "20:30";
path = [ pkgs.nix pkgs.gnutar pkgs.gzip pkgs.git pkgs.git-crypt ];
serviceConfig = {
Type = "oneshot";
WorkingDirectory = "/var/cache/gc-links";
ExecStart =
"${(import ../lib/test.nix).test-config}/bin/test-config bump";
{ pkgs, config, lib, ... }:
let
user = "maralorn";
inherit (import ../lib/test.nix) test-config;
inherit (import ../lib/update-system.nix config.system.build.nixos-rebuild)
update-system;
update-home = (import ../lib/update-home.nix).update-home "/etc/nixos";
in {
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 ];
restartIfChanged = false;
unitConfig.X-StopOnRemoval = false;
serviceConfig = {
Type = "oneshot";
WorkingDirectory = "/var/cache/gc-links";
};
script = ''
${test-config}/bin/test-config
/run/wrappers/bin/sudo -u ${user} git -C /etc/nixos pull
${update-system}/bin/update-system
/run/wrappers/bin/sudo -u ${user} ${update-home}/bin/update-home
'';
};
test-and-bump-config = {
startAt = "20:30";
path = [ pkgs.nix pkgs.gnutar pkgs.gzip pkgs.git pkgs.git-crypt ];
serviceConfig = {
Type = "oneshot";
WorkingDirectory = "/var/cache/gc-links";
ExecStart =
"${(import ../lib/test.nix).test-config}/bin/test-config bump";
};
};
};
}