From 7a3b464306f229361100419fd0e3b106897286b3 Mon Sep 17 00:00:00 2001 From: derped Date: Thu, 28 Oct 2021 15:03:55 +0200 Subject: [PATCH 1/5] Update i3 config. --- config/etc/i3/config | 9 +-------- config/etc/i3/py3status | 12 ++++++++++++ services/desktop/i3.nix | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/config/etc/i3/config b/config/etc/i3/config index 7097796..ea3a108 100644 --- a/config/etc/i3/config +++ b/config/etc/i3/config @@ -12,16 +12,9 @@ new_window pixel hide_edge_borders both exec setxkbmap de -exec xinput --map-to-output "ipts 045E:001F Pen Pen (0)" eDP1 -exec xinput --map-to-output "ipts 045E:001F Pen Eraser (0)" eDP1 -exec xinput --map-to-output "ipts 045E:001F Touchscreen" eDP1 - -bindsym $mod+Shift+s exec xinput --map-to-output "ipts 045E:001F Pen Pen (0)" eDP1; exec xinput --map-to-output "ipts 045E:001F Pen Eraser (0)" eDP1; exec xinput --map-to-output "ipts 045E:001F Touchscreen" eDP1 -bindsym $mod+Shift+a exec xinput --enable "ipts 045E:001F Touchscreen" -bindsym $mod+Shift+d exec xinput --disable "ipts 045E:001F Touchscreen" #exec compton -f -exec feh --bg-scale Pictures/wallpaper.jpg +exec feh --bg-scale $(xdg-user-dir PICTURES)/wallpaper.jpg #exec pulseaudio -D #exec fcitx #exec env=LC_CTYPE=zh_CN.UTF-8 emacs --daemon diff --git a/config/etc/i3/py3status b/config/etc/i3/py3status index 26bd898..f8ee423 100644 --- a/config/etc/i3/py3status +++ b/config/etc/i3/py3status @@ -18,6 +18,7 @@ order += "backlight" order += "volume_status" order += "cpu_temperature 0" order += "load" +order += "battery 0" order += "group tz" group network { @@ -65,6 +66,17 @@ group tz { } } +battery 0 { + format = "%status %percentage %remaining %emptytime" + format_down = "No battery" + status_chr = "⚡ CHR" + status_bat = "🔋 BAT" + status_unk = "? UNK" + status_full = "☻ FULL" + path = "/sys/class/power_supply/BAT%d/uevent" + low_threshold = 10 +} + volume_status { button_up = 4 button_down = 5 diff --git a/services/desktop/i3.nix b/services/desktop/i3.nix index 02916ca..a4856e8 100644 --- a/services/desktop/i3.nix +++ b/services/desktop/i3.nix @@ -7,10 +7,11 @@ { enable = true; configFile = ../../config/etc/i3/config; - extraPackages = with pkgs; [ + extraPackages = with pkgs; [ dmenu file i3lock i3status + xdg-user-dirs ]; } From 29b64aadfd8c963079e83440eeaa2872c3396923 Mon Sep 17 00:00:00 2001 From: derped Date: Thu, 28 Oct 2021 15:13:40 +0200 Subject: [PATCH 2/5] Add basic config for networkd. --- config/networking.nix | 37 ++++++++++++++++++++++++++++++++++++- options/machine.nix | 7 +++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/config/networking.nix b/config/networking.nix index bcdb93a..bb009b7 100644 --- a/config/networking.nix +++ b/config/networking.nix @@ -1,7 +1,42 @@ -{ config, ... }: +{ config, lib, ... }: + +with lib; { networking = { hostName = config.machine.hostName; + useNetworkd = config.machine.useNetworkd; + useDHCP = !config.machine.useNetworkd; + dhcpcd.enable = !config.machine.useNetworkd; }; + # Based on + # https://github.com/NixOS/nixpkgs/issues/10001#issuecomment-905532069 + systemd.network = mkIf config.machine.useNetworkd { + enable = true; + networks = let + networkConfig = { + DHCP = "yes"; + DNSSEC = "yes"; + DNSOverTLS = "yes"; + DNS = [ "1.1.1.1" "1.0.0.1" ]; + }; + in { + "40-wired" = { + enable = true; + name = "en*"; + dhcpV4Config.RouteMetric = 2048; + inherit networkConfig; + }; + "40-wireless" = { + enable = true; + name = "wl*"; + dhcpV4Config.RouteMetric = 1024; + inherit networkConfig; + }; + }; + }; + # Wait for any interface to become available, not for all + systemd.services."systemd-networkd-wait-online".serviceConfig.ExecStart = [ + "" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any" + ]; } diff --git a/options/machine.nix b/options/machine.nix index 5f8087f..4cce148 100644 --- a/options/machine.nix +++ b/options/machine.nix @@ -59,6 +59,13 @@ in { The Machines HostName ''; }; + useNetworkd = mkOption { + type = types.bool; + default = false; + description = '' + Disables dhcpcd and enables networkd. + ''; + }; binaryCaches = mkOption { type = types.listOf types.str; default = []; From 4305b3f653ed72acf635b5e044fc3c66ba9beb19 Mon Sep 17 00:00:00 2001 From: derped Date: Thu, 28 Oct 2021 15:18:03 +0200 Subject: [PATCH 3/5] Nspawn containers use host network for now. --- services/nspawn.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 services/nspawn.nix diff --git a/services/nspawn.nix b/services/nspawn.nix new file mode 100644 index 0000000..e0ebb4b --- /dev/null +++ b/services/nspawn.nix @@ -0,0 +1,28 @@ +{ config, lib, ... }: + +with lib; + +mkIf (elem "nspawn" config.machine.services) { + systemd = let + fn = import ../fn.nix { inherit lib; }; + in { + nspawn = recursiveUpdate (listToAttrs ( + (map ( + name: { + name = name; + value = { networkConfig.VirtualEthernet = "no"; }; + } + ) + (fn.lst { p = /var/lib/machines; t = "directory"; b = false; }) + ))) { + "64Arch" = { + filesConfig = { + "BindReadOnly" = ["/tmp/.X11-unix"]; + "Bind" = ["/dev/snd" "/dev/dri"]; + # TODO: Add this to service overrides + # "DeviceAllow" = [ "/dev/dri/renderD128" ]; + }; + }; + }; + }; +} From ff1388868441b9426fb2692c974cd03f57d309e9 Mon Sep 17 00:00:00 2001 From: derped Date: Thu, 28 Oct 2021 15:59:00 +0200 Subject: [PATCH 4/5] Remove nixops from base. --- pkgsets/base.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgsets/base.nix b/pkgsets/base.nix index 5462e7f..f12fb1e 100644 --- a/pkgsets/base.nix +++ b/pkgsets/base.nix @@ -32,7 +32,6 @@ nix-update-source nix-zsh-completions nixbang - nixops nmap nox ntfs3g From f7a10421a581ea03fc84ba3bf61a145f7c94d87f Mon Sep 17 00:00:00 2001 From: derped Date: Tue, 2 Nov 2021 09:44:06 +0100 Subject: [PATCH 5/5] Update to Nix 2.4 --- config/nix.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/nix.nix b/config/nix.nix index 058747e..15c0590 100644 --- a/config/nix.nix +++ b/config/nix.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ pkgs, config, lib, ... }: let cfg = config.machine; @@ -8,8 +8,11 @@ in { buildCores = 1; autoOptimiseStore = true; useSandbox = true; + package = pkgs.nix_2_4; + allowedUsers = [ "root" ] ++ (map (n: n.name) cfg.administrators); extraOptions = '' build-timeout = 86400 # 24 hours + experimental-features = nix-command flakes ''; binaryCachePublicKeys = [ (lib.fileContents "${cfg.secretPath}/hydra_cache.pub") ]; trustedBinaryCaches = [