From 91c8e77d254029cf32cc3756e39262e88f01167a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=A4dorf?= Date: Sun, 30 May 2021 21:33:09 +0200 Subject: [PATCH] Initial b12f commit --- .editorconfig | 8 + flake.lock | 211 +++++++++++++-- flake.nix | 2 + hosts/biolimo.nix | 6 + .../.config/sway/config.d/autostart.conf | 6 + .../sway/config.d/custom-keybindings.conf | 19 ++ .../.config/sway/config.d/input-defaults.conf | 9 + .../.config/sway/config.d/screens.conf | 21 ++ hosts/biolimo/.gitattributes | 1 + hosts/biolimo/configuration.nix | 96 +++++++ hosts/biolimo/default.nix | 28 ++ hosts/biolimo/hardware-configuration.nix | 36 +++ hosts/biolimo/secrets/keyfile.bin | Bin 0 -> 2070 bytes .../.config/sway/config.d/autostart.conf | 6 + .../sway/config.d/custom-keybindings.conf | 19 ++ .../.config/sway/config.d/input-defaults.conf | 9 + .../.config/sway/config.d/screens.conf | 21 ++ hosts/chocolatebar/.gitattributes | 1 + hosts/chocolatebar/default.nix | 28 ++ hosts/chocolatebar/secrets/.gitkeep | Bin 0 -> 22 bytes hosts/chocolatebar/secrets/crypto_keyfile.bin | Bin 0 -> 2070 bytes hosts/chocolatebar/secrets/hdd_keyfile.bin | Bin 0 -> 54 bytes hosts/chocolatebar/secrets/keyfile.bin | Bin 0 -> 2070 bytes .../virtualisation/create-service.nix | 78 ++++++ hosts/chocolatebar/virtualisation/default.nix | 52 ++++ .../virtualisation/generate-xml.nix | 242 ++++++++++++++++++ .../virtualisation/network-xml.nix | 19 ++ hosts/chocolatebar/virtualisation/rx550x.rom | Bin 0 -> 118272 bytes .../chocolatebar/virtualisation/rx5700xt.rom | Bin 0 -> 102912 bytes overlays/fonts.nix | 1 - overlays/fonts/default.nix | 4 - overlays/fonts/futura.nix | 19 -- users/ben/.config/msmtp/config | 31 +++ .../mutt/b.baedorf@openproject.com.muttrc | 24 ++ .../mutt/b.baedorf@openproject.com.signature | 19 ++ .../benjamin.baedorf@rwth-aachen.de.muttrc | 21 ++ .../mutt/hello@benjaminbaedorf.eu.muttrc | 21 ++ .../mutt/hello@benjaminbaedorf.eu.signature | 7 + users/ben/.config/offlineimap/config | 49 ++++ users/ben/.gitattributes | 1 + users/ben/default.nix | 35 +++ users/ben/home.nix | 50 ++++ users/ben/secrets/mopidy.conf | Bin 0 -> 454 bytes users/ben/session-variables.nix | 14 + 44 files changed, 1163 insertions(+), 51 deletions(-) create mode 100644 hosts/biolimo.nix create mode 100644 hosts/biolimo/.config/sway/config.d/autostart.conf create mode 100644 hosts/biolimo/.config/sway/config.d/custom-keybindings.conf create mode 100644 hosts/biolimo/.config/sway/config.d/input-defaults.conf create mode 100644 hosts/biolimo/.config/sway/config.d/screens.conf create mode 100644 hosts/biolimo/.gitattributes create mode 100644 hosts/biolimo/configuration.nix create mode 100644 hosts/biolimo/default.nix create mode 100644 hosts/biolimo/hardware-configuration.nix create mode 100644 hosts/biolimo/secrets/keyfile.bin create mode 100644 hosts/chocolatebar/.config/sway/config.d/autostart.conf create mode 100644 hosts/chocolatebar/.config/sway/config.d/custom-keybindings.conf create mode 100644 hosts/chocolatebar/.config/sway/config.d/input-defaults.conf create mode 100644 hosts/chocolatebar/.config/sway/config.d/screens.conf create mode 100644 hosts/chocolatebar/.gitattributes create mode 100644 hosts/chocolatebar/default.nix create mode 100644 hosts/chocolatebar/secrets/.gitkeep create mode 100644 hosts/chocolatebar/secrets/crypto_keyfile.bin create mode 100644 hosts/chocolatebar/secrets/hdd_keyfile.bin create mode 100644 hosts/chocolatebar/secrets/keyfile.bin create mode 100644 hosts/chocolatebar/virtualisation/create-service.nix create mode 100644 hosts/chocolatebar/virtualisation/default.nix create mode 100644 hosts/chocolatebar/virtualisation/generate-xml.nix create mode 100644 hosts/chocolatebar/virtualisation/network-xml.nix create mode 100644 hosts/chocolatebar/virtualisation/rx550x.rom create mode 100644 hosts/chocolatebar/virtualisation/rx5700xt.rom delete mode 100644 overlays/fonts.nix delete mode 100644 overlays/fonts/default.nix delete mode 100644 overlays/fonts/futura.nix create mode 100644 users/ben/.config/msmtp/config create mode 100644 users/ben/.config/mutt/b.baedorf@openproject.com.muttrc create mode 100644 users/ben/.config/mutt/b.baedorf@openproject.com.signature create mode 100644 users/ben/.config/mutt/benjamin.baedorf@rwth-aachen.de.muttrc create mode 100644 users/ben/.config/mutt/hello@benjaminbaedorf.eu.muttrc create mode 100644 users/ben/.config/mutt/hello@benjaminbaedorf.eu.signature create mode 100644 users/ben/.config/offlineimap/config create mode 100644 users/ben/.gitattributes create mode 100644 users/ben/default.nix create mode 100644 users/ben/home.nix create mode 100644 users/ben/secrets/mopidy.conf create mode 100644 users/ben/session-variables.nix diff --git a/.editorconfig b/.editorconfig index 96e5188b..0cce8f93 100644 --- a/.editorconfig +++ b/.editorconfig @@ -24,6 +24,14 @@ charset = unset indent_style = unset indent_size = unset +[*.rom] +end_of_line = unset +insert_final_newline = unset +trim_trailing_whitespace = unset +charset = unset +indent_style = unset +indent_size = unset + [*.py] indent_size = 4 diff --git a/flake.lock b/flake.lock index b0820712..17ba006e 100644 --- a/flake.lock +++ b/flake.lock @@ -15,11 +15,11 @@ "pre-commit-hooks-nix": "pre-commit-hooks-nix" }, "locked": { - "lastModified": 1619088868, - "narHash": "sha256-l9db+HpNIkY41MonGE8z4pbkjBa5BdzJTG5AxV7V7Lw=", + "lastModified": 1620750556, + "narHash": "sha256-J+z8oduu9u1FZ8spSowrgyAmtnBUIUDImqfQCZ58heo=", "owner": "hercules-ci", "repo": "hercules-ci-agent", - "rev": "08f953a263518a3af0ca28cd887020ff3465bdf5", + "rev": "f62ce85aed4c4a7fca9e5da2b00340bbcdc92f88", "type": "github" }, "original": { @@ -35,11 +35,11 @@ ] }, "locked": { - "lastModified": 1613595894, - "narHash": "sha256-MOk/7rCAUB5Lf4GL+HimvyAAZXYEw8gWsq5nW4PPQQA=", + "lastModified": 1622060422, + "narHash": "sha256-hPVlvrAyf6zL7tTx0lpK+tMxEfZeMiIZ/A2xaJ41WOY=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "5c3146b75d5d478f0693d0ea6c83f1da8382ff56", + "rev": "007d700e644ac588ad6668e6439950a5b6e2ff64", "type": "github" }, "original": { @@ -93,11 +93,11 @@ "utils": "utils_2" }, "locked": { - "lastModified": 1621354376, - "narHash": "sha256-b597Jj8B1Nq4NX/Gl/+bYGKqJxpSfUtr1Nmp9m1DND8=", + "lastModified": 1622093678, + "narHash": "sha256-WLD1RXE351WlYTwGmadXH7EGLGNOpnqgUFuJgYuhbQk=", "owner": "divnix", "repo": "digga", - "rev": "5ef9b8cabbc10c9b4fe5534107224c7241c63b3d", + "rev": "1b366811824635d249befa8bb046ac4c5f9f3494", "type": "github" }, "original": { @@ -138,6 +138,22 @@ "type": "github" } }, + "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1606424373, + "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1620759905, @@ -153,6 +169,36 @@ "type": "github" } }, + "flake-utils_2": { + "locked": { + "lastModified": 1610051610, + "narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1619345332, + "narHash": "sha256-qHnQkEp1uklKTpx3MvKtY6xzgcqXDsz5nLilbbuL+3A=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "2ebf2558e5bf978c7fb8ea927dfaed8fefab2e28", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home": { "inputs": { "nixpkgs": [ @@ -160,11 +206,11 @@ ] }, "locked": { - "lastModified": 1616724076, - "narHash": "sha256-SwbPXLjN2sLy4NL/GhodiJrdkIVZwGGTGiCN3JxH1cU=", + "lastModified": 1622368473, + "narHash": "sha256-5/HXUr8uv+L9ZerwEF3UefYL8Ik+j4uPoMpnxealANo=", "owner": "nix-community", "repo": "home-manager", - "rev": "fedfd430f96695997b3eaf8d7e82ca79406afa23", + "rev": "d2aaeac42c563cf8cf76ee3b90d9585dadbb91e0", "type": "github" }, "original": { @@ -175,11 +221,11 @@ }, "latest": { "locked": { - "lastModified": 1619400530, - "narHash": "sha256-7ZO7B+b9i1wFbHw62EFT+iwuBBpXeA/fcHlR63Z4J0w=", + "lastModified": 1622401687, + "narHash": "sha256-b8SraEekaRWvL2ylsFPTSKe92v7DgulpNI1Uy+cg7+4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e8dc8adab655eb27957859c62bef11484b53f639", + "rev": "0882e24b7148e54eca9722c39021590bff47c8c0", "type": "github" }, "original": { @@ -215,11 +261,11 @@ ] }, "locked": { - "lastModified": 1614785451, - "narHash": "sha256-TPw8kQvr2UNCuvndtY+EjyXp6Q5GEW2l9UafXXh1XmI=", + "lastModified": 1620316130, + "narHash": "sha256-sU0VS5oJS1FsHsZsLELAXc7G2eIelVuucRw+q5B1x9k=", "owner": "nmattia", "repo": "naersk", - "rev": "e0fe990b478a66178a58c69cf53daec0478ca6f9", + "rev": "a3f40fe42cc6d267ff7518fa3199e99ff1444ac4", "type": "github" }, "original": { @@ -228,6 +274,68 @@ "type": "github" } }, + "neovim-flake": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "dir": "contrib", + "lastModified": 1622347770, + "narHash": "sha256-reuhbVHdVGwvxyGq8fo/i1fVwqsoswQDb/YasgSPJ8k=", + "owner": "neovim", + "repo": "neovim", + "rev": "3cd688ff775a50808eb7d260e540038cc32b4a40", + "type": "github" + }, + "original": { + "dir": "contrib", + "owner": "neovim", + "repo": "neovim", + "type": "github" + } + }, + "neovim-nightly": { + "inputs": { + "flake-compat": "flake-compat_3", + "neovim-flake": "neovim-flake", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1622363948, + "narHash": "sha256-T+NW6joARJUAyGTQQDHvvVA/A7+3Af74rzW5z5JYqDQ=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "cbb6f94909c56ed3dca0a88bd170fbe985cdb82b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "type": "github" + } + }, + "nix-dram": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1620663773, + "narHash": "sha256-Nfc2g9xUCPYBFKE5O7OdrDpCVspwk64S8EbsDYoY38c=", + "owner": "dramforever", + "repo": "nix-dram", + "rev": "86485e22621b17bcc4472889eedbd562498bb5a2", + "type": "github" + }, + "original": { + "owner": "dramforever", + "repo": "nix-dram", + "type": "github" + } + }, "nixlib": { "locked": { "lastModified": 1620519687, @@ -245,11 +353,11 @@ }, "nixos": { "locked": { - "lastModified": 1615797423, - "narHash": "sha256-5NGDZXPQzuoxf/42NiyC9YwwhwzfMfIRrz3aT0XHzSc=", + "lastModified": 1622282707, + "narHash": "sha256-+GOrUDsdneUqrOm9d+9bHXjEVoVcU8tm14WGVzbt6gg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "266dc8c3d052f549826ba246d06787a219533b8f", + "rev": "6933d068c5d2fcff398e802f7c4e271bbdab6705", "type": "github" }, "original": { @@ -260,11 +368,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1615652054, - "narHash": "sha256-jqXKU8Ovpi7MmPRqGf2FB3QOPcZtGwO2MFc0AYiOPjg=", + "lastModified": 1622314052, + "narHash": "sha256-DwrLZ6NXPzKpQx3RTjdwdmlGDr6kHVx2gaeHCWCb09Q=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "31f61b90ddb9257b94888ee17ccf96236e180c76", + "rev": "684ae160a6e76590eafa3fca8061b6ad57bcc9ad", "type": "github" }, "original": { @@ -304,13 +412,59 @@ "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1622194753, + "narHash": "sha256-76qtvFp/vFEz46lz5iZMJ0mnsWQYmuGYlb0fHgKqqMg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "540dccb2aeaffa9dc69bfdc41c55abd7ccc6baa3", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1620340338, + "narHash": "sha256-Op/4K0+Z9Sp5jtFH0s/zMM4H7VFZxrekcAmjQ6JpQ4w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63586475587d7e0e078291ad4b49b6f6a6885100", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1622401687, + "narHash": "sha256-b8SraEekaRWvL2ylsFPTSKe92v7DgulpNI1Uy+cg7+4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0882e24b7148e54eca9722c39021590bff47c8c0", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, "nur": { "locked": { - "lastModified": 1615921934, - "narHash": "sha256-nURGM869KKA1+c1SHHsXKYcPXhHIuxWBjNXjJ90OzRQ=", + "lastModified": 1622390766, + "narHash": "sha256-MLV1KvZO8iQ6yDiLlJS/+HxFFh5u7K4oYVW+z42XyjI=", "owner": "nix-community", "repo": "NUR", - "rev": "faf862e8cf009edfa38ecc61188f7a6ace293552", + "rev": "8620d9071302235738c0c6616b36fa4410ba09fe", "type": "github" }, "original": { @@ -358,8 +512,11 @@ "home": "home", "latest": "latest", "naersk": "naersk_2", + "neovim-nightly": "neovim-nightly", + "nix-dram": "nix-dram", "nixos": "nixos", "nixos-hardware": "nixos-hardware", + "nixpkgs": "nixpkgs_5", "nur": "nur", "pkgs": "pkgs" } diff --git a/flake.nix b/flake.nix index 036e3db9..c3cf65a7 100644 --- a/flake.nix +++ b/flake.nix @@ -84,6 +84,8 @@ base = [ core users.nixos users.root ]; pubsolaros = [ core base-user users.root ]; anonymous = [ pubsolaros users.nixos ]; + b12f = [ pubsolaros users.ben ]; + biolimo = [ b12f graphical ]; }; }; diff --git a/hosts/biolimo.nix b/hosts/biolimo.nix new file mode 100644 index 00000000..64fd4b34 --- /dev/null +++ b/hosts/biolimo.nix @@ -0,0 +1,6 @@ +{ suites, ... }: +{ + imports = [ + ./biolimo + ] ++ suites.biolimo; +} diff --git a/hosts/biolimo/.config/sway/config.d/autostart.conf b/hosts/biolimo/.config/sway/config.d/autostart.conf new file mode 100644 index 00000000..173376b8 --- /dev/null +++ b/hosts/biolimo/.config/sway/config.d/autostart.conf @@ -0,0 +1,6 @@ +# Autostart applications +# +# Example: +# exec swayidle + +exec keepassxc diff --git a/hosts/biolimo/.config/sway/config.d/custom-keybindings.conf b/hosts/biolimo/.config/sway/config.d/custom-keybindings.conf new file mode 100644 index 00000000..4a954313 --- /dev/null +++ b/hosts/biolimo/.config/sway/config.d/custom-keybindings.conf @@ -0,0 +1,19 @@ +# Touchpad controls +#bindsym XF86TouchpadToggle exec $HOME/Workspace/ben/toggletouchpad.sh # toggle touchpad + +# Screen brightness controls +bindsym XF86MonBrightnessUp exec "brightnessctl -d intel_backlight set +10%; notify-send $(brightnessctl -d intel_backlight i | awk '/Current/ {print $4}')" +bindsym XF86MonBrightnessDown exec "brightnessctl -d intel_backlight set 10%-; notify-send $(brightnessctl -d intel_backlight i | awk '/Current/ { print $4}')" + +# Keyboard backlight brightness controls +bindsym XF86KbdBrightnessDown exec "brightnessctl -d smc::kbd_backlight set 10%-; notify-send $(brightnessctl -d smc::kbd_backlight i | awk '/Current/ { print $4}')" +bindsym XF86KbdBrightnessUp exec "brightnessctl -d smc::kbd_backlight set +10%; notify-send $(brightnessctl -d smc::kbd_backlight i | awk '/Current/ { print $4}')" + +# Pulse Audio controls +bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%; exec pactl set-sink-mute @DEFAULT_SINK@ 0 && notify-send 'Vol. up' #increase sound volume +bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%; exec pactl set-sink-mute @DEFAULT_SINK@ 0 && notify-send 'Vol. down' #decrease sound volume +bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle && notify-send 'Mute sound' # mute sound +# Media player controls +bindsym XF86AudioPlay exec "playerctl play-pause; notify-send 'Play/Pause'" +bindsym XF86AudioNext exec "playerctl next; notify-send 'Next'" +bindsym XF86AudioPrev exec "playerctl previous; notify-send 'Prev.'" diff --git a/hosts/biolimo/.config/sway/config.d/input-defaults.conf b/hosts/biolimo/.config/sway/config.d/input-defaults.conf new file mode 100644 index 00000000..426eb5b5 --- /dev/null +++ b/hosts/biolimo/.config/sway/config.d/input-defaults.conf @@ -0,0 +1,9 @@ +input "1739:0:Synaptics_TM3288-011" { + dwt enabled + tap enabled + middle_emulation enabled +} +input * { + xkb_layout us(intl),de + xkb_options ctrl:nocaps +} diff --git a/hosts/biolimo/.config/sway/config.d/screens.conf b/hosts/biolimo/.config/sway/config.d/screens.conf new file mode 100644 index 00000000..64869b63 --- /dev/null +++ b/hosts/biolimo/.config/sway/config.d/screens.conf @@ -0,0 +1,21 @@ +set $internal eDP-1 +set $middle "Hewlett Packard HP E231 3CQ4290S5J" +set $standup "Hewlett Packard HP E231 3CQ4251F33" + +output $internal { + scale 1.3 + pos 0 500 +} + +output $middle { + scale 1 + + # 1969 is the 1.3 scaled width of the internal monitor + pos 1969 0 +} + +output $standup { + scale 1 + transform 270 + pos 3889 0 +} diff --git a/hosts/biolimo/.gitattributes b/hosts/biolimo/.gitattributes new file mode 100644 index 00000000..793fb472 --- /dev/null +++ b/hosts/biolimo/.gitattributes @@ -0,0 +1 @@ +secrets/** filter=git-crypt-4406E80E13CD656C diff=git-crypt-4406E80E13CD656C diff --git a/hosts/biolimo/configuration.nix b/hosts/biolimo/configuration.nix new file mode 100644 index 00000000..76207fd3 --- /dev/null +++ b/hosts/biolimo/configuration.nix @@ -0,0 +1,96 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + imports = + [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # networking.hostName = "nixos"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Set your time zone. + # time.timeZone = "Europe/Amsterdam"; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Select internationalisation properties. + # i18n.defaultLocale = "en_US.UTF-8"; + # console = { + # font = "Lat2-Terminus16"; + # keyMap = "us"; + # }; + + # Enable the X11 windowing system. + # services.xserver.enable = true; + + + + + # Configure keymap in X11 + # services.xserver.layout = "us"; + # services.xserver.xkbOptions = "eurosign:e"; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + # sound.enable = true; + # hardware.pulseaudio.enable = true; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + # users.users.jane = { + # isNormalUser = true; + # extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + # }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + # environment.systemPackages = with pkgs; [ + # wget vim + # firefox + # ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "21.05"; # Did you read the comment? + +} + diff --git a/hosts/biolimo/default.nix b/hosts/biolimo/default.nix new file mode 100644 index 00000000..51f2e763 --- /dev/null +++ b/hosts/biolimo/default.nix @@ -0,0 +1,28 @@ +{ config, pkgs, lib, ... }: +with lib; +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; +in +{ + imports = [ + ./configuration.nix + ]; + + config = { + pub-solar.x-os.keyfile = "/etc/nixos/hosts/biolimo/secrets/keyfile.bin"; + + hardware.cpu.intel.updateMicrocode = true; + + networking.firewall.allowedTCPPorts = [ + 5000 + ]; + + home-manager.users."${psCfg.user.name}".xdg.configFile = mkIf psCfg.sway.enable { + "sway/config.d/10-screens.conf".source = ./.config/sway/config.d/screens.conf; + "sway/config.d/10-autostart.conf".source = ./.config/sway/config.d/autostart.conf; + "sway/config.d/10-input-defaults.conf".source = ./.config/sway/config.d/input-defaults.conf; + "sway/config.d/10-custom-keybindings.conf".source = ./.config/sway/config.d/custom-keybindings.conf; + }; + }; +} diff --git a/hosts/biolimo/hardware-configuration.nix b/hosts/biolimo/hardware-configuration.nix new file mode 100644 index 00000000..dcd07866 --- /dev/null +++ b/hosts/biolimo/hardware-configuration.nix @@ -0,0 +1,36 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/abc3fe04-368e-46eb-8c7a-3a829bb2deab"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."cryptroot".device = "/dev/disk/by-uuid/aed21f8d-8e15-4f43-8710-460cb36d488b"; + + fileSystems."/boot/efi" = + { + device = "/dev/disk/by-uuid/3B67-0CAB"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + # high-resolution display + hardware.video.hidpi.enable = lib.mkDefault true; +} diff --git a/hosts/biolimo/secrets/keyfile.bin b/hosts/biolimo/secrets/keyfile.bin new file mode 100644 index 0000000000000000000000000000000000000000..143d8bcd637f42804c8c5fd0f183ec56538ba759 GIT binary patch literal 2070 zcmV+x2H$<9<5*_QBp^)v`Q1m zk3P!Yss>R9J(y>d)g%M&h`dCoGe{jm4qQr3X~%;TiW_)p1ZgrtMjndcsP_9Obl#kj zX91BPp1tjl&(GQ9>JP+VtI*GAp9H+8H{*BE<{~Z`FiPs?Zo6pg>A2`So8q;#L`W%} zU^H)Ydf(m--B*}DEY(cZ0VU~e=%!ZVie&OUKpW>5w~G6QsOkZV3KXu*O8-Xv{7BvC z;Rf^hG<;jIO3A`Z@mWnhi@4w&e2S2Yy)kX zg-tgUeaENIy-Lu!CZLIly5lAuE$L-%;*Eo3S-Nd#=g-M{2c-1v=g#Fsz!YCN;S1y+ zN_v~`;CBe4M!!h|VY|&ItI*z;bgiSSL=DCnZ}~7GLVC4%;o(k@mte0N9@<)JojObL zY!&Ynk1>5en9cF!1uHF}KX=)i^~55XEs6Y!WK! z?~?p2VeCy_^;@n@bE!dW*Z(!C^nXgGad&fSM%K>UxDxiC#Q{_c#2I`@zE1@6xK&xXBmjgwTK306t%ywppeh}403OD5j+K>nI=u_-Pep6R}h0G2AfAI9ua2( z8ZfV!@I4c9BVP0TLG~%3uy>mFI0>EB#eJ1IkTo>80&IHAcz7{r@P0wF2N^-bsr;2+ z#K@mq+;P)^AUk?_$VG&MGYzv%f@~Fh_|lp(RXQ`h*jh8iIz;uIjT<^V+HC*z45Arb zZzl1iRf`GuC4tGXjzXf=RyxekdWJ&I2h*ynIc5SgHAnTU@skiLO&N5B|L&=bCt=Mx zpVGi*vZ%1|z$Ng2d9IS}5d{eSW}Shl-H0H7=v4WvuVLc`9NLcQsp;=&DSGK_i~%IGz2(9Gg`vg{q#j z(pH!0T@DHzrsoE!@v&Ye**MzhUHm1WrI}x6-QVr2Z?jM`-uRq(-7^74yfc=9UBZXa z)ubFQ8D4^0{nP0+i{bU;-UkY$58k&tB@MB@LcPpX_Q8E&dgqp7f~nMp z7>)WQN^(B{ZD>x6ywzEGjfz_)WM(|*D_^na$#3|MpfQ|K5^|QTWkvpJcRv#g- zVkXrpKYHE&j*ais^#HN0Pl2Pckw4RsVy6eF|SMm_B z`q`!4>Ry37m_^;^MfSnnzp;(dPN7M($qBHmcoG0!l^qI3;?B-dC5^#0bkg zZBJ$jkZB&uDFbx{T_%|Kb7%lJc#l_66pOmj5{l=iTd-^yqzk|0@SeyE`Q+gu8X44l zqv{r_{99ulMp9cusa-mpB{d}N`9sv3Obo>n`CGnvW!{yvR*WS^LP0*OT>AW);+ek{ AjsO4v literal 0 HcmV?d00001 diff --git a/hosts/chocolatebar/.config/sway/config.d/autostart.conf b/hosts/chocolatebar/.config/sway/config.d/autostart.conf new file mode 100644 index 00000000..173376b8 --- /dev/null +++ b/hosts/chocolatebar/.config/sway/config.d/autostart.conf @@ -0,0 +1,6 @@ +# Autostart applications +# +# Example: +# exec swayidle + +exec keepassxc diff --git a/hosts/chocolatebar/.config/sway/config.d/custom-keybindings.conf b/hosts/chocolatebar/.config/sway/config.d/custom-keybindings.conf new file mode 100644 index 00000000..4a954313 --- /dev/null +++ b/hosts/chocolatebar/.config/sway/config.d/custom-keybindings.conf @@ -0,0 +1,19 @@ +# Touchpad controls +#bindsym XF86TouchpadToggle exec $HOME/Workspace/ben/toggletouchpad.sh # toggle touchpad + +# Screen brightness controls +bindsym XF86MonBrightnessUp exec "brightnessctl -d intel_backlight set +10%; notify-send $(brightnessctl -d intel_backlight i | awk '/Current/ {print $4}')" +bindsym XF86MonBrightnessDown exec "brightnessctl -d intel_backlight set 10%-; notify-send $(brightnessctl -d intel_backlight i | awk '/Current/ { print $4}')" + +# Keyboard backlight brightness controls +bindsym XF86KbdBrightnessDown exec "brightnessctl -d smc::kbd_backlight set 10%-; notify-send $(brightnessctl -d smc::kbd_backlight i | awk '/Current/ { print $4}')" +bindsym XF86KbdBrightnessUp exec "brightnessctl -d smc::kbd_backlight set +10%; notify-send $(brightnessctl -d smc::kbd_backlight i | awk '/Current/ { print $4}')" + +# Pulse Audio controls +bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%; exec pactl set-sink-mute @DEFAULT_SINK@ 0 && notify-send 'Vol. up' #increase sound volume +bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%; exec pactl set-sink-mute @DEFAULT_SINK@ 0 && notify-send 'Vol. down' #decrease sound volume +bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle && notify-send 'Mute sound' # mute sound +# Media player controls +bindsym XF86AudioPlay exec "playerctl play-pause; notify-send 'Play/Pause'" +bindsym XF86AudioNext exec "playerctl next; notify-send 'Next'" +bindsym XF86AudioPrev exec "playerctl previous; notify-send 'Prev.'" diff --git a/hosts/chocolatebar/.config/sway/config.d/input-defaults.conf b/hosts/chocolatebar/.config/sway/config.d/input-defaults.conf new file mode 100644 index 00000000..426eb5b5 --- /dev/null +++ b/hosts/chocolatebar/.config/sway/config.d/input-defaults.conf @@ -0,0 +1,9 @@ +input "1739:0:Synaptics_TM3288-011" { + dwt enabled + tap enabled + middle_emulation enabled +} +input * { + xkb_layout us(intl),de + xkb_options ctrl:nocaps +} diff --git a/hosts/chocolatebar/.config/sway/config.d/screens.conf b/hosts/chocolatebar/.config/sway/config.d/screens.conf new file mode 100644 index 00000000..1337a8dc --- /dev/null +++ b/hosts/chocolatebar/.config/sway/config.d/screens.conf @@ -0,0 +1,21 @@ +set $internal eDP-1 +set $middle DP-4 +set $standup DP-5 + +output $internal { + scale 1.3 + pos 0 500 +} + +output $middle { + scale 1 + + # 1969 is the 1.3 scaled width of the internal monitor + pos 1969 0 +} + +output $standup { + scale 1 + transform 270 + pos 3889 0 +} diff --git a/hosts/chocolatebar/.gitattributes b/hosts/chocolatebar/.gitattributes new file mode 100644 index 00000000..793fb472 --- /dev/null +++ b/hosts/chocolatebar/.gitattributes @@ -0,0 +1 @@ +secrets/** filter=git-crypt-4406E80E13CD656C diff=git-crypt-4406E80E13CD656C diff --git a/hosts/chocolatebar/default.nix b/hosts/chocolatebar/default.nix new file mode 100644 index 00000000..8f25b802 --- /dev/null +++ b/hosts/chocolatebar/default.nix @@ -0,0 +1,28 @@ +{ config, pkgs, lib, ... }: +with lib; +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; +in +{ + imports = [ + ./virtualisation + ]; + + config = { + pub-solar.virtualisation.enable = true; + + hardware.cpu.amd.updateMicrocode = true; + + hardware.opengl.extraPackages = with pkgs; [ + rocm-opencl-icd + rocm-opencl-runtime + ]; + + home-manager.users."${psCfg.user.name}".xdg.configFile = mkIf psCfg.sway.enable { + "sway/config.d/10-autostart.conf".source = ./.config/sway/config.d/autostart.conf; + "sway/config.d/10-input-defaults.conf".source = ./.config/sway/config.d/input-defaults.conf; + "sway/config.d/10-screens.conf".source = ./.config/sway/config.d/screens.conf; + }; + }; +} diff --git a/hosts/chocolatebar/secrets/.gitkeep b/hosts/chocolatebar/secrets/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..43bd4fb3660b2b523249ad729a18c3776ac88d82 GIT binary patch literal 22 dcmZQ@_Y83kiVO&0cyjI%+uq7$G0C^>LjYQ%2?_uJ literal 0 HcmV?d00001 diff --git a/hosts/chocolatebar/secrets/crypto_keyfile.bin b/hosts/chocolatebar/secrets/crypto_keyfile.bin new file mode 100644 index 0000000000000000000000000000000000000000..ca34df9d0c4aa91f557f23974b638603ddd7f07e GIT binary patch literal 2070 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 AGynhq literal 0 HcmV?d00001 diff --git a/hosts/chocolatebar/virtualisation/create-service.nix b/hosts/chocolatebar/virtualisation/create-service.nix new file mode 100644 index 00000000..f3eab3b0 --- /dev/null +++ b/hosts/chocolatebar/virtualisation/create-service.nix @@ -0,0 +1,78 @@ +{ config, pkgs, lib, vm, ... }: +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + varsFile = "${xdg.dataHome}/libvirt/OVMF_VARS_${vm.name}.fd"; + generateXML = import ./generate-xml.nix; +in +{ + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = "yes"; + Restart = "no"; + }; + + script = + let + networkXML = pkgs.writeText "network.xml" (import ./network-xml.nix { inherit config; inherit pkgs; inherit lib; }); + machineXML = pkgs.writeText "${vm.name}.xml" (generateXML { inherit config; inherit pkgs; inherit lib; inherit vm; varsFile = varsFile; }); + in + '' + echo "Checking if ${vm.name} is already running" + STATUS=$(${pkgs.libvirt}/bin/virsh list --all | grep "${vm.name}" | ${pkgs.gawk}/bin/awk '{ print $3 " " $4 }' ) + if [[ $STATUS != "shut off" && $STATUS != "" ]]; then + echo "Domain ${vm.name} is already running or in an inconsistent state:" + ${pkgs.libvirt}/bin/virsh list --all + exit 0 + fi + + NET_TMP_FILE="/tmp/network.xml" + + NETUUID="$(${pkgs.libvirt}/bin/virsh net-uuid 'default' || true)" + (sed "s/UUID/$NETUUID/" '${networkXML}') > $NET_TMP_FILE + + ${pkgs.libvirt}/bin/virsh net-define $NET_TMP_FILE + ${pkgs.libvirt}/bin/virsh net-start 'default' || true + + VARS_FILE=${varsFile} + if [ ! -f "$VARS_FILE" ]; then + cp /run/libvirt/nix-ovmf/OVMF_VARS.fd $VARS_FILE + fi + + TMP_FILE="/tmp/${vm.name}.xml" + + UUID="$(${pkgs.libvirt}/bin/virsh domuuid '${vm.name}' || true)" + (sed "s/UUID/$UUID/" '${machineXML}') > $TMP_FILE + + USB_DEV=$(${pkgs.usbutils}/bin/lsusb | grep 046d:c52b | grep 'Bus 001' | cut -b 18) + LINE_NUMBER=$(cat $TMP_FILE | grep -n -A 1 0xc52b | tail -n 1 | cut -b 1,2,3) + sed -i "''${LINE_NUMBER}s/\(.\{33\}\)./\1''${USB_DEV}/" $TMP_FILE + + USB_BUS=$(${pkgs.usbutils}/bin/lsusb | grep 046d:c328 | cut -b 7) + USB_DEV=$(${pkgs.usbutils}/bin/lsusb | grep 046d:c328 | cut -b 18) + LINE_NUMBER=$(cat $TMP_FILE | grep -n -A 1 0xc328 | tail -n 1 | cut -b 1,2,3) + sed -i "''${LINE_NUMBER}s/.*/
/" $TMP_FILE + + # TODO: Set correct pci address too + + ${pkgs.libvirt}/bin/virsh define $TMP_FILE + ${pkgs.libvirt}/bin/virsh start '${vm.name}' + ''; + + preStop = + '' + ${pkgs.libvirt}/bin/virsh shutdown '${vm.name}' + let "timeout = $(date +%s) + 10" + while [ "$(${pkgs.libvirt}/bin/virsh list --name | grep --count '^${vm.name}$')" -gt 0 ]; do + if [ "$(date +%s)" -ge "$timeout" ]; then + # Meh, we warned it... + ${pkgs.libvirt}/bin/virsh destroy '${vm.name}' + else + # The machine is still running, let's give it some time to shut down + sleep 0.5 + fi + done + + ${pkgs.libvirt}/bin/virsh net-destroy 'default' || true + ''; +} diff --git a/hosts/chocolatebar/virtualisation/default.nix b/hosts/chocolatebar/virtualisation/default.nix new file mode 100644 index 00000000..a024ab6c --- /dev/null +++ b/hosts/chocolatebar/virtualisation/default.nix @@ -0,0 +1,52 @@ +{ config, pkgs, lib, ... }: +with lib; +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + createService = import ./create-service.nix; + isolateAnyGPU = psCfg.virtualisation.isolateGPU != null; +in +{ + options.pub-solar.virtualisation.isolateGPU = mkOption { + description = "Which GPU to isolate for virtualisation guests"; + type = with types; nullOr (enum [ "rx5700xt" "rx550x" ]); + default = null; + }; + + config = mkIf psCfg.virtualisation.enable { + boot.extraModprobeConfig = mkIf isolateAnyGPU (concatStringsSep "\n" [ + "softdep amdgpu pre: vfio vfio_pci" + (if psCfg.virtualisation.isolateGPU == "rx5700xt" + then "options vfio-pci ids=1002:731f,1002:ab38" + else "options vfio-pci ids=1002:699f,1002:aae0" + ) + ]); + + systemd.user.services = { + vm-windows = createService { + inherit config; + inherit pkgs; + inherit lib; + vm = { + name = "windows"; + disk = "/dev/disk/by-id/ata-SanDisk_SDSSDA240G_162402455603"; + id = "http://microsoft.com/win/10"; + gpu = true; + mountHome = false; + }; + }; + vm-manjaro = createService { + inherit config; + inherit pkgs; + inherit lib; + vm = { + name = "manjaro"; + disk = "/dev/disk/by-id/ata-KINGSTON_SM2280S3G2240G_50026B726B0265CE"; + id = "https://manjaro.org/download/#i3"; + gpu = true; + mountHome = true; + }; + }; + }; + }; +} diff --git a/hosts/chocolatebar/virtualisation/generate-xml.nix b/hosts/chocolatebar/virtualisation/generate-xml.nix new file mode 100644 index 00000000..69e96ab4 --- /dev/null +++ b/hosts/chocolatebar/virtualisation/generate-xml.nix @@ -0,0 +1,242 @@ +{ config, pkgs, lib, vm, varsFile, ... }: +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + home = config.home-manager.users."${psCfg.user.name}".home; +in +'' + + ${vm.name} + UUID + + + + + + 33554432 + 33554432 + 12 + + + + + + + + + + + + + + + + /machine + + + hvm + /run/libvirt/nix-ovmf/OVMF_CODE.fd + ${varsFile} + + + + + + + + + + + + + + + + + + EPYC-IBPB + AMD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + destroy + restart + destroy + + + + + + ${pkgs.qemu}/bin/qemu-system-x86_64 + + + + + +
+ + +
+ + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + +
+ + + + +
+ + +
+ + ${if vm.mountHome then '' + + + +
+ + '' else ""} + + + + +
+ + + + + + + + + + +
+ + + + + + + +