diff --git a/.drone.yml b/.drone.yml index b4d4bb92..4cf4b3b2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,12 +1,11 @@ --- kind: pipeline -type: exec +type: docker name: Check -node: - hosttype: baremetal steps: - name: "Check" + image: docker.nix-community.org/nixpkgs/nix-flakes:latest when: event: - pull_request @@ -21,8 +20,6 @@ steps: kind: pipeline type: exec name: Tests -node: - hosttype: baremetal steps: - name: "Tests" @@ -148,6 +145,6 @@ volumes: --- kind: signature -hmac: 291be33bbf2954d1f5e4bf569679e24a773e7d6f90db4765fb9dacb3686a825e +hmac: 3e6a89e903e214f21d488eba82863683b130ef6dbc2dc352377d4fd94ab3cd0c ... 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/.gitignore b/.gitignore index 37acdb01..012da5d3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ vm iso doi -pkgs/_sources/.shake* - +# PubSolarOS tags /owners +pkgs/_sources/.shake* diff --git a/flake.lock b/flake.lock index 060a2aea..ba2292ac 100644 --- a/flake.lock +++ b/flake.lock @@ -42,11 +42,11 @@ ] }, "locked": { - "lastModified": 1667419884, - "narHash": "sha256-oLNw87ZI5NxTMlNQBv1wG2N27CUzo9admaFlnmavpiY=", + "lastModified": 1667294277, + "narHash": "sha256-YhVGYUpPZNpJZ8z3Sq9aT6n1/B8vKtfRfwaCtbsosxk=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "cfc0125eafadc9569d3d6a16ee928375b77e3100", + "rev": "b7177030643374e698c29e993c2808efa7b85aaf", "type": "github" }, "original": { @@ -205,22 +205,6 @@ "type": "github" } }, - "flake-compat_4": { - "flake": false, - "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-utils": { "locked": { "lastModified": 1642700792, @@ -272,11 +256,11 @@ }, "flake-utils_3": { "locked": { - "lastModified": 1667077288, - "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "owner": "numtide", "repo": "flake-utils", - "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", "type": "github" }, "original": { @@ -292,11 +276,11 @@ ] }, "locked": { - "lastModified": 1667677389, - "narHash": "sha256-y9Zdq8vtsn0T5TO1iTvWA7JndYIAGjzCjbYVi/hOSmA=", + "lastModified": 1667299227, + "narHash": "sha256-vAJPFSDYUq3DdCL8OzTg4xObRNW+yA1Pt+NzbhGu1f8=", "owner": "nix-community", "repo": "home-manager", - "rev": "87d55517f6f36aa1afbd7a4a064869d5a1d405b8", + "rev": "f0ecd4b1db5e15103e955b18cb94bea4296e5c45", "type": "github" }, "original": { @@ -324,11 +308,11 @@ }, "latest_2": { "locked": { - "lastModified": 1667629849, - "narHash": "sha256-P+v+nDOFWicM4wziFK9S/ajF2lc0N2Rg9p6Y35uMoZI=", + "lastModified": 1667231093, + "narHash": "sha256-RERXruzBEBuf0c7OfZeX1hxEKB+PTCUNxWeB6C1jd8Y=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3bacde6273b09a21a8ccfba15586fb165078fb62", + "rev": "d40fea9aeb8840fea0d377baa4b38e39b9582458", "type": "github" }, "original": { @@ -338,6 +322,22 @@ "type": "github" } }, + "master": { + "locked": { + "lastModified": 1667394072, + "narHash": "sha256-RFTHGjI46hg3ggVwSdssAsni5q5YRsQl2SENv5PPAnQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "07c0c2707bfc78e2b615eb69977ffc6e366c5ec6", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, "naersk": { "inputs": { "nixpkgs": [ @@ -375,11 +375,11 @@ }, "nixos": { "locked": { - "lastModified": 1667653703, - "narHash": "sha256-Xow4vx52/g5zkhlgZnMEm/TEXsj+13jTPCc2jIhW1xU=", + "lastModified": 1667318659, + "narHash": "sha256-mRXqCdlnxPgm3Wk7mNAOanl7B3Q3U5scYTEiyYmNEOE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f09ad462c5a121d0239fde645aacb2221553a217", + "rev": "b3a8f7ed267e0a7ed100eb7d716c9137ff120fe3", "type": "github" }, "original": { @@ -410,11 +410,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1667768008, - "narHash": "sha256-PGbX0s2hhXGnZDFVE6UIhPSOf5YegpWs5dUXpT/14F0=", + "lastModified": 1667283320, + "narHash": "sha256-qHvB/6XBKVjjJJCUM+z6/t9HzUC7J55wdY3KJ/ZWSHo=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "f6483e0def85efb9c1e884efbaff45a5e7aabb34", + "rev": "18934557eeba8fa2e575b0fd4ab95186e2e3bde3", "type": "github" }, "original": { @@ -469,18 +469,18 @@ }, "nvfetcher": { "inputs": { - "flake-compat": "flake-compat_4", + "flake-compat": "flake-compat_3", "flake-utils": "flake-utils_3", "nixpkgs": [ "nixos" ] }, "locked": { - "lastModified": 1667620329, - "narHash": "sha256-v1Zk7rtEbAGpevBGPZvZBKpwbmw4I+uVwxvd+pBlp3o=", + "lastModified": 1667246446, + "narHash": "sha256-LTnDoH6B8cez7RAc7K/DJqFrnZr75OMtVsNqtIHIPBU=", "owner": "berberman", "repo": "nvfetcher", - "rev": "294826951113dcd3aa9abbcacfb1aa5b95a19116", + "rev": "d5d1289327f26e870991656b2c5598ce62693311", "type": "github" }, "original": { @@ -489,21 +489,38 @@ "type": "github" } }, + "pub-solar": { + "locked": { + "lastModified": 1654372286, + "narHash": "sha256-z1WrQkL67Sosz1VnuKQLpzEkEl4ianeLpWJX8Q6bVQY=", + "owner": "pub-solar", + "repo": "nixpkgs", + "rev": "4995a873a796c54cc49e5dca9e1d20350eceec7b", + "type": "github" + }, + "original": { + "owner": "pub-solar", + "ref": "fix/use-latest-unstable-yubikey-agent", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", "darwin": "darwin", "deploy": "deploy", "digga": "digga", - "flake-compat": "flake-compat_3", "home": "home", "latest": "latest_2", + "master": "master", "naersk": "naersk", "nixos": "nixos", "nixos-generators": "nixos-generators", "nixos-hardware": "nixos-hardware", "nur": "nur", - "nvfetcher": "nvfetcher" + "nvfetcher": "nvfetcher", + "pub-solar": "pub-solar" } }, "utils": { diff --git a/flake.nix b/flake.nix index cce3f8ee..d4c44813 100644 --- a/flake.nix +++ b/flake.nix @@ -10,9 +10,8 @@ # Track channels with commits tested and built by hydra nixos.url = "github:nixos/nixpkgs/nixos-22.05"; latest.url = "github:nixos/nixpkgs/nixos-unstable"; - - flake-compat.url = "github:edolstra/flake-compat"; - flake-compat.flake = false; + master.url = "github:nixos/nixpkgs/master"; + pub-solar.url = "github:pub-solar/nixpkgs/fix/use-latest-unstable-yubikey-agent"; digga.url = "github:pub-solar/digga/fix/bootstrap-iso"; digga.inputs.nixpkgs.follows = "nixos"; @@ -60,7 +59,7 @@ inherit self inputs; channelsConfig = { - # allowUnfree = true; + allowUnfree = true; }; supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; @@ -71,6 +70,7 @@ overlays = [ ]; }; latest = { }; + master = { }; }; lib = import ./lib { lib = digga.lib // nixos.lib; }; @@ -128,6 +128,13 @@ iso = base ++ [ base-user graphical pub-solar-iso ]; pubsolaros = [ full-install base-user users.root ]; anonymous = [ pubsolaros users.pub-solar ]; + + b12f = pubsolaros ++ [ users.ben social gaming mobile ]; + biolimo = b12f ++ [ graphical ]; + chocolatebar = b12f ++ [ graphical virtualisation ]; + + yule = pubsolaros ++ [ users.yule ]; + droppie = yule ++ [ ]; }; }; }; @@ -138,11 +145,13 @@ importables = rec { profiles = digga.lib.rakeLeaves ./users/profiles; suites = with profiles; rec { - base = [ direnv git ]; + base = [ direnv ]; }; }; users = { pub-solar = { suites, ... }: { imports = suites.base; }; + ben = { suites, ... }: { imports = suites.base; }; + yule = { suites, ... }: { imports = suites.base; }; }; # digga.lib.importers.rakeLeaves ./users/hm; }; @@ -150,6 +159,10 @@ homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations; - deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { }; + deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { + droppie = { + sshUser = "yule"; + }; + }; }; } 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..f95c13c2 --- /dev/null +++ b/hosts/biolimo/.config/sway/config.d/screens.conf @@ -0,0 +1,20 @@ +set $internal eDP-1 +set $middle "Hewlett Packard HP E231 3CQ4290S5J" +set $standup "Hewlett Packard HP E231 3CQ4251F33" + +output $internal { + scale 1 + pos 1080 1080 +} + +output $middle { + scale 1 + + pos 1080 0 +} + +output $standup { + scale 1 + transform 90 + pos 0 0 +} diff --git a/hosts/biolimo/biolimo.nix b/hosts/biolimo/biolimo.nix new file mode 100644 index 00000000..b02053d1 --- /dev/null +++ b/hosts/biolimo/biolimo.nix @@ -0,0 +1,36 @@ +{ 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.paranoia.enable = true; + pub-solar.core.hibernation.resumeDevice = "/dev/dm-0"; + pub-solar.core.hibernation.resumeOffset = 15296512; + + hardware.cpu.intel.updateMicrocode = true; + + networking.firewall.allowedTCPPorts = [ 5000 ]; + + networking.networkmanager.wifi.backend = mkForce "wpa_supplicant"; + + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "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; + }; + + home.packages = [ + inkscape + ]; + }; + }; +} diff --git a/hosts/biolimo/configuration.nix b/hosts/biolimo/configuration.nix new file mode 100644 index 00000000..9f4a341a --- /dev/null +++ b/hosts/biolimo/configuration.nix @@ -0,0 +1,26 @@ +# 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; + + # 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 = "20.09"; # Did you read the comment? +} + diff --git a/hosts/biolimo/default.nix b/hosts/biolimo/default.nix new file mode 100644 index 00000000..26d7e453 --- /dev/null +++ b/hosts/biolimo/default.nix @@ -0,0 +1,6 @@ +{ suites, ... }: +{ + imports = [ + ./biolimo.nix + ] ++ suites.biolimo; +} diff --git a/hosts/biolimo/hardware-configuration.nix b/hosts/biolimo/hardware-configuration.nix new file mode 100644 index 00000000..309bb376 --- /dev/null +++ b/hosts/biolimo/hardware-configuration.nix @@ -0,0 +1,38 @@ +# 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" = { + device = "/dev/disk/by-uuid/3B67-0CAB"; + fsType = "vfat"; + }; + + swapDevices = [ + { + device = "/swapfile"; + size = 18 * 1024; # 18 GB + } + ]; + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + # high-resolution display + hardware.video.hidpi.enable = lib.mkDefault true; +} 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..24725e0a --- /dev/null +++ b/hosts/chocolatebar/.config/sway/config.d/input-defaults.conf @@ -0,0 +1,4 @@ +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..25869c20 --- /dev/null +++ b/hosts/chocolatebar/.config/sway/config.d/screens.conf @@ -0,0 +1,18 @@ +set $left DP-3 +set $middle DP-1 +set $right HDMI-A-1 + +output $left { + scale 1 + pos 0 0 +} + +output $middle { + scale 1 + pos 1920 0 +} + +output $right { + scale 1 + pos 3840 0 +} diff --git a/hosts/chocolatebar/chocolatebar.nix b/hosts/chocolatebar/chocolatebar.nix new file mode 100644 index 00000000..bb13dce9 --- /dev/null +++ b/hosts/chocolatebar/chocolatebar.nix @@ -0,0 +1,64 @@ +{ config, pkgs, lib, self, ... }: +with lib; +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; +in +{ + imports = [ + ./configuration.nix + ./virtualisation + ./factorio + ]; + + config = { + hardware.cpu.amd.updateMicrocode = true; + + hardware.opengl.extraPackages = with pkgs; [ + rocm-opencl-icd + rocm-opencl-runtime + ]; + + pub-solar.core.hibernation.resumeDevice = "/dev/dm-0"; + pub-solar.core.hibernation.resumeOffset = 115075072; + + services.openssh.openFirewall = true; + networking.firewall.allowedTCPPorts = [ 443 ] ++ (if psCfg.sway.vnc.enable then [ 5901 ] else [ ]); + + environment.systemPackages = with pkgs; [ + wayvnc + drone-docker-runner + stdenv.cc.cc.lib + ]; + + age.secrets."vnc-key.pem" = { + file = "${self}/secrets/vnc-key-chocolatebar.pem"; + mode = "400"; + owner = psCfg.user.name; + }; + age.secrets."vnc-cert.pem" = { + file = "${self}/secrets/vnc-cert-chocolatebar.pem"; + mode = "400"; + owner = psCfg.user.name; + }; + pub-solar.sway.vnc.enable = true; + pub-solar.ci-runner.enable = true; + + 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; + }; + + home.sessionVariables = { + NIX_CC = "${pkgs.stdenv.cc}"; + }; + }; + + # For OpenProject development with https + security.pki.certificates = [ + (builtins.readFile ./step-roots.pem) + ]; + }; +} diff --git a/hosts/chocolatebar/configuration.nix b/hosts/chocolatebar/configuration.nix new file mode 100644 index 00000000..4cdd96fd --- /dev/null +++ b/hosts/chocolatebar/configuration.nix @@ -0,0 +1,25 @@ +# 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; + + # 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 = "20.09"; # Did you read the comment? +} diff --git a/hosts/chocolatebar/default.nix b/hosts/chocolatebar/default.nix new file mode 100644 index 00000000..d7548796 --- /dev/null +++ b/hosts/chocolatebar/default.nix @@ -0,0 +1,6 @@ +{ suites, ... }: +{ + imports = [ + ./chocolatebar.nix + ] ++ suites.chocolatebar; +} diff --git a/hosts/chocolatebar/factorio/default.nix b/hosts/chocolatebar/factorio/default.nix new file mode 100644 index 00000000..4c818bec --- /dev/null +++ b/hosts/chocolatebar/factorio/default.nix @@ -0,0 +1,38 @@ +{ config, pkgs, lib, self, ... }: +with lib; +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + + far-reach = pkgs.stdenv.mkDerivation rec { + pname = "factorio-far-reach"; + version = "1.1.2"; + src = ./far-reach_1.1.2.zip; + phases = [ "installPhase" ]; + deps = [ ]; + installPhase = '' + mkdir -p $out + cp $src far-reach_1.1.2.zip + ''; + }; +in +{ + config = { + services.factorio = { + enable = true; + port = 34197; # The default, but make it explicit + lan = true; + admins = [ + "doubtwriter" + "kattykat" + ]; + openFirewall = true; + autosave-interval = 3; + game-name = "Babes plays v2"; + requireUserVerification = false; + mods = [ + far-reach + ]; + }; + }; +} diff --git a/hosts/chocolatebar/factorio/far-reach_1.1.2.zip b/hosts/chocolatebar/factorio/far-reach_1.1.2.zip new file mode 100644 index 00000000..4bae7ec8 Binary files /dev/null and b/hosts/chocolatebar/factorio/far-reach_1.1.2.zip differ diff --git a/hosts/chocolatebar/hardware-configuration.nix b/hosts/chocolatebar/hardware-configuration.nix new file mode 100644 index 00000000..7437b2dd --- /dev/null +++ b/hosts/chocolatebar/hardware-configuration.nix @@ -0,0 +1,38 @@ +# 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 = [ "nvme" "xhci_pci" "ahci" "usbcore" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/a3a74208-b244-4268-b374-e58265810fce"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."cryptroot".device = "/dev/disk/by-uuid/afcde41f-9811-4ac8-bb7b-a683844acc5c"; + + fileSystems."/boot" = + { + device = "/dev/disk/by-uuid/12FD-62A8"; + fsType = "vfat"; + }; + + swapDevices = [ + { + device = "/swapfile"; + size = 68 * 1024; # 68 GB + } + ]; + +} diff --git a/hosts/chocolatebar/step-roots.pem b/hosts/chocolatebar/step-roots.pem new file mode 100644 index 00000000..0e90e42d --- /dev/null +++ b/hosts/chocolatebar/step-roots.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB6DCCAY2gAwIBAgIQD4Q4blCl/ZrTIRU2QpqEOTAKBggqhkjOPQQDAjBSMSMw +IQYDVQQKExpPcGVuUHJvamVjdCBEZXZlbG9wbWVudCBDQTErMCkGA1UEAxMiT3Bl +blByb2plY3QgRGV2ZWxvcG1lbnQgQ0EgUm9vdCBDQTAeFw0yMjEwMTgxMTE1NDBa +Fw0zMjEwMTUxMTE1NDBaMFIxIzAhBgNVBAoTGk9wZW5Qcm9qZWN0IERldmVsb3Bt +ZW50IENBMSswKQYDVQQDEyJPcGVuUHJvamVjdCBEZXZlbG9wbWVudCBDQSBSb290 +IENBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEu4rN0lOtgxoC83UKONMy2Ns7 +tI0/u6qPp/Cw92xhaTdh/X9ZWKqIhp2VGj2HUJOOfQXrFew7jbLGOvvoXib0Y6NF +MEMwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQEwHQYDVR0OBBYE +FPjV1zK2GZu8x4uR0QDotk5kNinEMAoGCCqGSM49BAMCA0kAMEYCIQDS2OpCnHM7 +RV7fFHT3KsG3q4lA3dJUKGighQaQ2qOwNwIhAOMmWGWd3EaD87q4RROyVt3h7vIN +nMJRu7L9il84hFF2 +-----END CERTIFICATE----- diff --git a/hosts/chocolatebar/virtualisation/create-service.nix b/hosts/chocolatebar/virtualisation/create-service.nix new file mode 100644 index 00000000..b88c089b --- /dev/null +++ b/hosts/chocolatebar/virtualisation/create-service.nix @@ -0,0 +1,97 @@ +{ 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 ./guest-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" (vm.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 + + echo "Creating network XML" + NET_TMP_FILE="/tmp/network.xml" + + NETUUID="$(${pkgs.libvirt}/bin/virsh net-uuid 'default' || true)" + (sed "s/UUID/$NETUUID/" '${networkXML}') > "$NET_TMP_FILE" + + echo "Defining and starting network" + ${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 + echo "Copying vars filej" + cp /run/libvirt/nix-ovmf/OVMF_VARS.fd "$VARS_FILE" + fi + + echo "Replacing USB device IDs in the XML" + # Load the template contents into a tmp file + TMP_FILE="/tmp/${vm.name}.xml" + cat "${machineXML}" > "$TMP_FILE" + + # Set VM UUID + UUID="$(${pkgs.libvirt}/bin/virsh domuuid '${vm.name}' || true)" + sed -i "s/UUID/''${UUID}/" "$TMP_FILE" + + ${if vm.handOverUSBDevices then '' + # Hand over mouse + USB_BUS=5 + USB_DEV=$(${pkgs.usbutils}/bin/lsusb | grep 046d:c52b | grep 'Bus 005' | 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/.*/
/" "$TMP_FILE" + + # Hand over keyboard + 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" + '' else ""} + + # TODO: Set correct pci address for the GPU too + + # Setup looking glass shm file + echo "Setting up looking glass shm file" + ${pkgs.coreutils-full}/bin/truncate -s 0 /dev/shm/looking-glass + ${pkgs.coreutils-full}/bin/dd if=/dev/zero of=/dev/shm/looking-glass bs=1M count=32 + + # Load and start the xml definition + echo "Loading and starting the VM XML definition" + ${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..043e3f23 --- /dev/null +++ b/hosts/chocolatebar/virtualisation/default.nix @@ -0,0 +1,78 @@ +{ config, pkgs, lib, ... }: +with lib; +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + createService = import ./create-service.nix; + generateXML = import ./guest-xml.nix; + generateTailsXML = import ./tails-xml.nix; + + isolateGPU = "rx550x"; + memory = 48; # in GB + handOverUSBDevices = true; + + isolateAnyGPU = isolateGPU != null; +in +{ + config = mkIf psCfg.virtualisation.enable { + boot.extraModprobeConfig = mkIf isolateAnyGPU (concatStringsSep "\n" [ + "softdep amdgpu pre: vfio vfio_pci" + (if 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; + memory = memory; + isolateGPU = isolateGPU; + handOverUSBDevices = handOverUSBDevices; + generateXML = generateXML; + }; + }; + 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; + memory = memory; + isolateGPU = isolateGPU; + handOverUSBDevices = handOverUSBDevices; + generateXML = generateXML; + }; + }; + vm-tails = createService { + inherit config; + inherit pkgs; + inherit lib; + vm = { + name = "tails"; + disk = "/var/lib/vms/tails/tails-amd64-5.4.iso"; + # disk = "/var/lib/vms/nixos/nixos-minimal.iso"; + id = "https://tails.boum.org/install/index.en.html"; + gpu = false; + mountHome = false; + memory = 16; + isolateGPU = isolateGPU; + handOverUSBDevices = false; + generateXML = generateTailsXML; + }; + }; + }; + }; +} diff --git a/hosts/chocolatebar/virtualisation/guest-xml.nix b/hosts/chocolatebar/virtualisation/guest-xml.nix new file mode 100644 index 00000000..876c6714 --- /dev/null +++ b/hosts/chocolatebar/virtualisation/guest-xml.nix @@ -0,0 +1,246 @@ +{ 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 + + + + + + ${toString vm.memory} + ${toString vm.memory} + 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 ""} + + + + +
+ + + + + +
+ + + + + + + +