From 31dcdf1d7cd38df227f86171c074f83d375feb82 Mon Sep 17 00:00:00 2001 From: Toast Date: Mon, 17 Jul 2023 13:11:53 +0200 Subject: [PATCH 1/4] Machines: Add Surface Go --- flake.nix | 14 +++ machines/SurfaceGo/configuration.nix | 103 ++++++++++++++++++ machines/SurfaceGo/default.nix | 8 ++ machines/SurfaceGo/hardware-configuration.nix | 58 ++++++++++ 4 files changed, 183 insertions(+) create mode 100644 machines/SurfaceGo/configuration.nix create mode 100644 machines/SurfaceGo/default.nix create mode 100644 machines/SurfaceGo/hardware-configuration.nix diff --git a/flake.nix b/flake.nix index 8f48cb0..b2108d7 100755 --- a/flake.nix +++ b/flake.nix @@ -62,6 +62,20 @@ outputs = {nixpkgs, nixpkgs-unstable, agenix, home-manager, home-manager-unstabl ]; }; + SurfaceGo = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + # Needed for nix-index + { nix.nixPath = [ "nixpkgs=${nixpkgs}" ]; } + agenix.nixosModules.default + home-manager.nixosModule + ./roles/common + ./roles/desktop + ./roles/kde + ./machines/SurfaceGo + ]; + }; + Everest = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ diff --git a/machines/SurfaceGo/configuration.nix b/machines/SurfaceGo/configuration.nix new file mode 100644 index 0000000..f0e31af --- /dev/null +++ b/machines/SurfaceGo/configuration.nix @@ -0,0 +1,103 @@ +# 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, ... }: + +{ + # Use grub boot loader + boot.loader = { + systemd-boot.enable = false; + grub = { + enable = true; + device = "nodev"; + efiSupport = true; + enableCryptodisk = true; + }; + efi = { + efiSysMountPoint = "/boot/efi"; + canTouchEfiVariables = true; + }; + }; + + networking.hostName = "SurfaceGo"; # Define your hostname. + networking.networkmanager.enable = true; # Enable networking + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # Set your time zone. + time.timeZone = "Europe/Madrid"; + + # 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 = { + keyMap = "es"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the pipewire sound server + services.pipewire = { + enable = true; + pulse.enable = true; + }; + + # Configure keymap in X11 + # services.xserver.layout = "us"; + # services.xserver.xkbOptions = "eurosign:e,caps:escape"; + + # 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.toast = { + 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; [ + # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + # wget + # ]; + + # 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; + + # Copy the NixOS configuration file and link it from the resulting system + # (/run/current-system/configuration.nix). This is useful in case you + # accidentally delete configuration.nix. + # system.copySystemConfiguration = true; + +} + diff --git a/machines/SurfaceGo/default.nix b/machines/SurfaceGo/default.nix new file mode 100644 index 0000000..5bf2485 --- /dev/null +++ b/machines/SurfaceGo/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./configuration.nix + ./hardware-configuration.nix + ]; +} diff --git a/machines/SurfaceGo/hardware-configuration.nix b/machines/SurfaceGo/hardware-configuration.nix new file mode 100644 index 0000000..e8f4999 --- /dev/null +++ b/machines/SurfaceGo/hardware-configuration.nix @@ -0,0 +1,58 @@ + # 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" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + boot.initrd.luks.devices."SSD".device = "/dev/disk/by-uuid/1d8d7578-d3a1-4ea0-90ad-4257266a6caf"; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/19a52b40-3ff6-47ff-9402-18d8b289643e"; + fsType = "btrfs"; + options = [ "subvol=@" "compress=zstd" ]; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/19a52b40-3ff6-47ff-9402-18d8b289643e"; + fsType = "btrfs"; + options = [ "subvol=@boot" "compress=zstd" ]; + }; + + fileSystems."/nix" ={ + device = "/dev/disk/by-uuid/19a52b40-3ff6-47ff-9402-18d8b289643e"; + fsType = "btrfs"; + options = [ "subvol=@nix" "compress=zstd" ]; + }; + + fileSystems."/home" = { + device = "/dev/disk/by-uuid/19a52b40-3ff6-47ff-9402-18d8b289643e"; + fsType = "btrfs"; + options = [ "subvol=@home" "compress=zstd" ]; + }; + + /*fileSystems."/swap" = { + device = "/dev/disk/by-uuid/19a52b40-3ff6-47ff-9402-18d8b289643e"; + fsType = "btrfs"; + options = [ "subvol=@swapfile" ]; + };*/ + + fileSystems."/boot/efi" = { + device = "/dev/disk/by-uuid/EC76-201F"; + fsType = "vfat"; + }; + + swapDevices = []; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} From 582fe1b01b1fdf17228d844140fa128bb83fcbdb Mon Sep 17 00:00:00 2001 From: Toast Date: Mon, 17 Jul 2023 13:15:52 +0200 Subject: [PATCH 2/4] Flake: fix formatting --- flake.nix | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index b2108d7..b30b03b 100755 --- a/flake.nix +++ b/flake.nix @@ -2,29 +2,29 @@ description = "Configuration for Everest"; inputs = { -nixpkgs.url = "nixpkgs/nixos-23.05"; -nixpkgs-unstable.url = "nixpkgs/nixos-unstable"; + nixpkgs.url = "nixpkgs/nixos-23.05"; + nixpkgs-unstable.url = "nixpkgs/nixos-unstable"; -agenix = { - url = "github:ryantm/agenix"; - inputs = { - nixpkgs.follows = "nixpkgs"; - darwin.follows = ""; # Not using this on MacOS, so this doesn't pull it's dependencies + agenix = { + url = "github:ryantm/agenix"; + inputs = { + nixpkgs.follows = "nixpkgs"; + darwin.follows = ""; # Not using this on MacOS, so this doesn't pull it's dependencies + }; }; -}; -home-manager = { - url = "github:nix-community/home-manager/release-23.05"; - inputs.nixpkgs.follows = "nixpkgs"; -}; + home-manager = { + url = "github:nix-community/home-manager/release-23.05"; + inputs.nixpkgs.follows = "nixpkgs"; + }; -home-manager-unstable = { - url = "github:nix-community/home-manager/"; - inputs.nixpkgs.follows = "nixpkgs-unstable"; -}; + home-manager-unstable = { + url = "github:nix-community/home-manager/"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; + }; -nix-impermanence.url = "github:nix-community/impermanence"; -}; + nix-impermanence.url = "github:nix-community/impermanence"; + }; outputs = {nixpkgs, nixpkgs-unstable, agenix, home-manager, home-manager-unstable, nix-impermanence, ... }: { devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell { From f9830c2dfe9aa8345b8c755fb620294afe0d4294 Mon Sep 17 00:00:00 2001 From: Toast Date: Wed, 19 Jul 2023 10:37:43 +0200 Subject: [PATCH 3/4] Flake: add nixos-hardware --- flake.lock | 17 +++++++++++++++++ flake.nix | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index 4a32b35..d288db1 100644 --- a/flake.lock +++ b/flake.lock @@ -99,6 +99,22 @@ "type": "github" } }, + "nixos-hardware": { + "locked": { + "lastModified": 1689320556, + "narHash": "sha256-vODUkZLWFVCvo1KPK3dC2CbXjxa9antEn5ozwlcTr48=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "d4ea64f2063820120c05f6ba93ee02e6d4671d6b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1689137672, @@ -135,6 +151,7 @@ "home-manager": "home-manager_2", "home-manager-unstable": "home-manager-unstable", "nix-impermanence": "nix-impermanence", + "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable" } diff --git a/flake.nix b/flake.nix index b30b03b..6051319 100755 --- a/flake.nix +++ b/flake.nix @@ -23,10 +23,12 @@ inputs = { inputs.nixpkgs.follows = "nixpkgs-unstable"; }; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + nix-impermanence.url = "github:nix-community/impermanence"; }; -outputs = {nixpkgs, nixpkgs-unstable, agenix, home-manager, home-manager-unstable, nix-impermanence, ... }: { +outputs = {nixpkgs, nixpkgs-unstable, agenix, home-manager, home-manager-unstable, nixos-hardware, nix-impermanence, ... }: { devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell { name = "Environment for toast's nixos configurations"; # The agenix cli is not needed to activate a configuration, so instead of installing it From 9220a6acb115bbe0e92c32de1bb6c70c36ba5e5d Mon Sep 17 00:00:00 2001 From: Toast Date: Wed, 19 Jul 2023 10:41:04 +0200 Subject: [PATCH 4/4] SurfaceGo: use nixos-hardware module --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 6051319..f2270f8 100755 --- a/flake.nix +++ b/flake.nix @@ -71,6 +71,7 @@ outputs = {nixpkgs, nixpkgs-unstable, agenix, home-manager, home-manager-unstabl { nix.nixPath = [ "nixpkgs=${nixpkgs}" ]; } agenix.nixosModules.default home-manager.nixosModule + nixos-hardware.nixosModules.microsoft-surface-go ./roles/common ./roles/desktop ./roles/kde