From 209525b7e2ddef05b9f503f4b5ec3a84531a56da Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Thu, 20 Jul 2023 11:15:39 +0200 Subject: [PATCH] Add host: `bennu` - Separate nixpkgs for `sombrero` from `bennu` --- Makefile | 6 +- flake.lock | 49 +++++++++-- flake.nix | 34 ++++++-- hosts/bennu/configs/.gitconfig | 13 +++ hosts/bennu/configuration.nix | 107 +++++++++++++++++++++++++ hosts/bennu/hardware-configuration.nix | 40 +++++++++ hosts/bennu/home.nix | 24 ++++++ 7 files changed, 258 insertions(+), 15 deletions(-) create mode 100644 hosts/bennu/configs/.gitconfig create mode 100644 hosts/bennu/configuration.nix create mode 100644 hosts/bennu/hardware-configuration.nix create mode 100644 hosts/bennu/home.nix diff --git a/Makefile b/Makefile index 7036e2a..0873c94 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: switch +.PHONY: bennu-switch -switch: - nixos-rebuild switch --flake '.#' +bennu-switch: + nixos-rebuild switch --flake .#bennu diff --git a/flake.lock b/flake.lock index b74acbe..b32c7be 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,33 @@ { "nodes": { - "nixpkgs": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs2305" + ] + }, "locked": { - "lastModified": 1686929285, - "narHash": "sha256-WGtVzn+vGMPTXDO0DMNKVFtf+zUSqeW+KKk4Y/Ae99I=", + "lastModified": 1687871164, + "narHash": "sha256-bBFlPthuYX322xOlpJvkjUBz0C+MOBjZdDOOJJ+G2jU=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "07c347bb50994691d7b0095f45ebd8838cf6bc38", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.05", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs2211": { + "locked": { + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "93fddcf640ceca0be331210ba3101cee9d91c13d", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", "type": "github" }, "original": { @@ -16,9 +37,27 @@ "type": "github" } }, + "nixpkgs2305": { + "locked": { + "lastModified": 1689605451, + "narHash": "sha256-u2qp2k9V1smCfk6rdUcgMKvBj3G9jVvaPHyeXinjN9E=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "53657afe29748b3e462f1f892287b7e254c26d77", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "home-manager": "home-manager", + "nixpkgs2211": "nixpkgs2211", + "nixpkgs2305": "nixpkgs2305" } } }, diff --git a/flake.nix b/flake.nix index 3ab5e80..18bc434 100644 --- a/flake.nix +++ b/flake.nix @@ -1,12 +1,32 @@ { - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; - }; + description = "nixos configs"; - outputs = inputs@{ self, nixpkgs }: { - nixosConfigurations.sombrero = nixpkgs.lib.nixosSystem { - system = "aarch64-linux"; - modules = [ ./hosts/sombrero/configuration.nix ]; + inputs = { + nixpkgs2305.url = "github:nixos/nixpkgs/nixos-23.05"; + nixpkgs2211.url = "github:nixos/nixpkgs/nixos-22.11"; + home-manager.url = "github:nix-community/home-manager/release-23.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs2305"; + }; + + outputs = { self, nixpkgs2305, nixpkgs2211, home-manager, ... }: { + nixosConfigurations = { + bennu = nixpkgs2305.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./hosts/bennu/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.alex = import ./hosts/bennu/home.nix; + } + ]; + }; + + sombrero = nixpkgs2211.lib.nixosSystem { + system = "aarch64-linux"; + modules = [ ./hosts/sombrero/configuration.nix ]; + }; }; }; } diff --git a/hosts/bennu/configs/.gitconfig b/hosts/bennu/configs/.gitconfig new file mode 100644 index 0000000..d8d800e --- /dev/null +++ b/hosts/bennu/configs/.gitconfig @@ -0,0 +1,13 @@ +[user] + name = Alexander Heldt + email = me@alexanderheldt.se + +[core] + editor = "vim" + +[url "git@github.com:"] + insteadOf = https://github.com/ + +[url "git@gitlab.com:"] + insteadOf = https://gitlab.com/ + diff --git a/hosts/bennu/configuration.nix b/hosts/bennu/configuration.nix new file mode 100644 index 0000000..d77a95c --- /dev/null +++ b/hosts/bennu/configuration.nix @@ -0,0 +1,107 @@ +# 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 + ]; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Setup keyfile + boot.initrd.secrets = { + "/crypto_keyfile.bin" = null; + }; + + networking.hostName = "bennu"; # Define your hostname. + #networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "Europe/Stockholm"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "sv_SE.UTF-8"; + LC_IDENTIFICATION = "sv_SE.UTF-8"; + LC_MEASUREMENT = "sv_SE.UTF-8"; + LC_MONETARY = "sv_SE.UTF-8"; + LC_NAME = "sv_SE.UTF-8"; + LC_NUMERIC = "sv_SE.UTF-8"; + LC_PAPER = "sv_SE.UTF-8"; + LC_TELEPHONE = "sv_SE.UTF-8"; + LC_TIME = "sv_SE.UTF-8"; + }; + + # Configure keymap in X11 + services.xserver = { + enable = true; + layout = "se"; + xkbVariant = ""; + + displayManager.gdm.enable = true; + desktopManager.gnome.enable = true; + }; + + # Configure console keymap + console.keyMap = "sv-latin1"; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.alex = { + isNormalUser = true; + description = "alex"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; []; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; []; + + # 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 = "23.05"; # Did you read the comment? + +} diff --git a/hosts/bennu/hardware-configuration.nix b/hosts/bennu/hardware-configuration.nix new file mode 100644 index 0000000..22a7802 --- /dev/null +++ b/hosts/bennu/hardware-configuration.nix @@ -0,0 +1,40 @@ +# 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" "thunderbolt" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/9c3ef2ad-0244-4310-9984-2e548ced3e22"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-f569d036-e500-4839-bc78-ce4b032840d8".device = "/dev/disk/by-uuid/f569d036-e500-4839-bc78-ce4b032840d8"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/FCAE-6849"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + + # 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.wlp0s20f3.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/bennu/home.nix b/hosts/bennu/home.nix new file mode 100644 index 0000000..798cb66 --- /dev/null +++ b/hosts/bennu/home.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: +{ + programs.home-manager.enable = true; + + home.username = "alex"; + home.homeDirectory = "/home/alex"; + + home.packages = with pkgs; [ + vim + emacs + gnumake + tig + firefox-devedition-unwrapped + ]; + + programs.git = { + enable = true; + includes = [ + { path = ./configs/.gitconfig; } + ]; + }; + + home.stateVersion = "23.05"; +}