From a643c27306a11d5d05925e12f9c858f83857b764 Mon Sep 17 00:00:00 2001 From: seb314 Date: Fri, 12 Apr 2024 23:29:36 +0200 Subject: [PATCH] minimal nixos setup for FW16 (iGPU) with kde --- .envrc | 2 + .gitignore | 1 + README.md | 7 ++ flake.lock | 65 ++++++++++++++ flake.nix | 51 +++++++++++ hosts/FW16/configuration.nix | 50 +++++++++++ hosts/FW16/default.nix | 15 ++++ hosts/FW16/disko.nix | 123 ++++++++++++++++++++++++++ hosts/FW16/hardware-configuration.nix | 28 ++++++ 9 files changed, 342 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 README.md create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/FW16/configuration.nix create mode 100644 hosts/FW16/default.nix create mode 100644 hosts/FW16/disko.nix create mode 100644 hosts/FW16/hardware-configuration.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..03bb5ed --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +watch_file flake.nix +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..29963da --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.direnv/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..3b9809a --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +This is a rather minimal nixos configuration for the Framework Laptop 16 +(iGPU-only version). +**Intended only as a sanity check to get a config with working graphics.** + +Boots successfully, KDE seems to work, wifi works. + +(Installed on ZFS on LUKS, partitioned and formatted with disko). diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..21001bb --- /dev/null +++ b/flake.lock @@ -0,0 +1,65 @@ +{ + "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712947906, + "narHash": "sha256-T0eT2lMbcK7RLelkx0qx4SiFpOS/0dt0aSfLB+WsGV8=", + "owner": "nix-community", + "repo": "disko", + "rev": "8d4ae698eaac8bd717e23507da2ca8b345bec4b5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "nixos-hardware": { + "locked": { + "lastModified": 1712909959, + "narHash": "sha256-7/5ubuwdEbQ7Z+Vqd4u0mM5L2VMNDsBh54visp27CtQ=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "f58b25254be441cd2a9b4b444ed83f1e51244f1f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1712741485, + "narHash": "sha256-bCs0+MSTra80oXAsnM6Oq62WsirOIaijQ/BbUY59tR4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b2cf36f43f9ef2ded5711b30b1f393ac423d8f72", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "disko": "disko", + "nixos-hardware": "nixos-hardware", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..46e553b --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = "Pruned Nixos Config for FW16 Standalone"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = + { self + , nixpkgs + , ... + } @ inputs: + let + inherit (self) outputs; + systems = [ + #"aarch64-linux" + #"i686-linux" + "x86_64-linux" + #"aarch64-darwin" + #"x86_64-darwin" + ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + in + { + nixosConfigurations = { + FW16 = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; + modules = [ + ./hosts/FW16/default.nix + ]; + }; + }; + + devShells = forAllSystems (system: + let pkgs = (import nixpkgs {inherit system; }); + in { + default = pkgs.mkShell { + buildInputs = [ + pkgs.nil + pkgs.nixos-anywhere + ]; + }; + } + ); + }; +} diff --git a/hosts/FW16/configuration.nix b/hosts/FW16/configuration.nix new file mode 100644 index 0000000..34c3b48 --- /dev/null +++ b/hosts/FW16/configuration.nix @@ -0,0 +1,50 @@ +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: { + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.initrd.supportedFilesystems = [ "zfs" ]; + boot.supportedFilesystems = [ "zfs" ]; + services.zfs.autoScrub.enable = true; + networking.hostId = "8dabc8e2"; + + networking.hostName = "FW16"; + networking.networkmanager.enable = true; + + services.openssh = { + openFirewall = true; + enable = true; + settings = { + PasswordAuthentication = lib.mkDefault false; + KbdInteractiveAuthentication = lib.mkDefault false; + }; + }; + users.users.root.openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6Rb9XzpoStRNCqOeY7NCTprq/+NSlTiha6gDtslZJxX/YmmufoPtPwNA/F+32SFTCt2EXSoXhUL5/jzYH3+6uWdCVmZd1nSChCKV3AiyEJ7CK3I/41O7ljw3XoP2TtODnf6xSZKWUc3Eo2SEbuswzTE4yBJ5Pew3CvA1RUpqUDfFDFEi0RuzcbEx6zSbKQLDJja6v6s3dxijTNaFeH4JcnISx4X/3OjhRzmJ/44dcIjwjJwhDx/QkPRzm+HnthrjGUO3zrsX43NyNqfz9eu+YKT9iZmHIJlOKt1SCADDn3PspjXqrpb/LdYaAgjxLmK4bm7tIPryH5Xg6hKtTE7jJ sebastian@oldlaptop" + ]; + + services.xserver.enable = true; + services.xserver.displayManager.sddm.enable = true; + services.xserver.desktopManager.plasma5.enable = true; + + users.mutableUsers = true; + users.users.nixos = { + password = "nixos"; + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; + + # 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 = "23.11"; # Did you read the comment? +} + diff --git a/hosts/FW16/default.nix b/hosts/FW16/default.nix new file mode 100644 index 0000000..780eb87 --- /dev/null +++ b/hosts/FW16/default.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, + inputs, + ... }: +{ + imports = [ + ./hardware-configuration.nix + + inputs.nixos-hardware.nixosModules.framework-13-7040-amd + + ./disko.nix + inputs.disko.nixosModules.disko + + ./configuration.nix + ]; +} diff --git a/hosts/FW16/disko.nix b/hosts/FW16/disko.nix new file mode 100644 index 0000000..da1c769 --- /dev/null +++ b/hosts/FW16/disko.nix @@ -0,0 +1,123 @@ +{ + disko.devices = { + disk = { + nvme0n1 = { + type = "disk"; + #device = "/dev/nvme0n1"; + device = "/dev/disk/by-id/nvme-WD_BLACK_SN850X_2000GB_23509Q446109_1"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ + "defaults" + ]; + }; + }; + ESP2 = { # spare in case we need to install a second os or so + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = null; + mountOptions = [ + "defaults" + ]; + }; + }; + luks = { + end = "-100G"; + content = { + type = "luks"; + name = "crypted"; + extraOpenArgs = [ ]; + askPassword = true; + settings = { + # if you want to use the key for interactive login be sure there is no trailing newline + # for example use `echo -n "password" > /tmp/secret.key` + #keyFile = "/tmp/secret.key"; + allowDiscards = true; # TODO? + #crypttabExtraOpts = [ "tpm2-device=auto" ]; + }; + #additionalKeyFiles = [ "/tmp/additionalSecret.key" ]; + content = { + type = "zfs"; + pool = "zroot"; + # zpool = { + # zroot = { + # type = "zpool"; + # datasets = { + # "root" = { + # type = "zfs_fs"; + # options.mountpoint = "none"; + # }; + # "root/root" = { + # type = "zfs_fs"; + # mountpoint = "/"; + # #options."com.sun:auto-snapshot" = "true"; + # }; + # "root/home" = { + # type = "zfs_fs"; + # mountpoint = "/home"; + # #options."com.sun:auto-snapshot" = "true"; + # }; + # "root/nix" = { + # type = "zfs_fs"; + # mountpoint = "/nix"; + # #options."com.sun:auto-snapshot" = "true"; + # }; + # "root/var" = { + # type = "zfs_fs"; + # mountpoint = "/var"; + # #options."com.sun:auto-snapshot" = "true"; + # }; + # }; + # }; + # }; + }; + }; + }; + }; + }; + }; + }; + zpool = { + zroot = { + type = "zpool"; + datasets = { + "root" = { + type = "zfs_fs"; + options.mountpoint = "none"; + }; + "root/root" = { + type = "zfs_fs"; + mountpoint = "/"; + #options."com.sun:auto-snapshot" = "true"; + }; + "root/home" = { + type = "zfs_fs"; + mountpoint = "/home"; + #options."com.sun:auto-snapshot" = "true"; + }; + "root/nix" = { + type = "zfs_fs"; + mountpoint = "/nix"; + #options."com.sun:auto-snapshot" = "true"; + }; + "root/var" = { + type = "zfs_fs"; + mountpoint = "/var"; + #options."com.sun:auto-snapshot" = "true"; + }; + }; + }; + }; + }; +} diff --git a/hosts/FW16/hardware-configuration.nix b/hosts/FW16/hardware-configuration.nix new file mode 100644 index 0000000..8fcabe7 --- /dev/null +++ b/hosts/FW16/hardware-configuration.nix @@ -0,0 +1,28 @@ +# 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" "thunderbolt" "usbhid" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + # NOTE file systems handled by disko + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp195s0f3u1.useDHCP = lib.mkDefault true; + # networking.interfaces.vboxnet0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +}