From c8ccbac32ca99b5f61af4397c436c8b204c574ea Mon Sep 17 00:00:00 2001 From: Ethan Simmons Date: Fri, 14 Jun 2024 20:32:52 -0500 Subject: [PATCH] Change flake.nix to allow different nixpkgs versions --- flake.lock | 61 +++++++++++++++++++----- flake.nix | 61 +++++++++++++++++++----- hosts/alpheratz/system.nix | 1 - hosts/default/hardware-configuration.nix | 45 +++++++++++++++++ hosts/default/home.nix | 23 +++++++++ hosts/default/system.nix | 39 +++++++++++++++ main.log | 11 ----- modules/nix/common.nix | 5 ++ modules/nix/networking.nix | 1 + overlays/llama-cpp.nix | 6 --- 10 files changed, 211 insertions(+), 42 deletions(-) create mode 100644 hosts/default/hardware-configuration.nix create mode 100644 hosts/default/home.nix create mode 100644 hosts/default/system.nix delete mode 100644 main.log delete mode 100644 overlays/llama-cpp.nix diff --git a/flake.lock b/flake.lock index 8e254eb..ce353f2 100644 --- a/flake.lock +++ b/flake.lock @@ -30,18 +30,39 @@ "type": "github" } }, - "home-manager": { + "home-manager-stable": { "inputs": { "nixpkgs": [ - "nixpkgs" + "nixpkgs-stable" ] }, "locked": { - "lastModified": 1717525419, - "narHash": "sha256-5z2422pzWnPXHgq2ms8lcCfttM0dz+hg+x1pCcNkAws=", + "lastModified": 1717527182, + "narHash": "sha256-vWSkg6AMok1UUQiSYVdGMOXKD2cDFnajITiSi0Zjd1A=", "owner": "nix-community", "repo": "home-manager", - "rev": "a7117efb3725e6197dd95424136f79147aa35e5b", + "rev": "845a5c4c073f74105022533907703441e0464bc3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-24.05", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager-unstable": { + "inputs": { + "nixpkgs": [ + "nixpkgs-unstable" + ] + }, + "locked": { + "lastModified": 1718243258, + "narHash": "sha256-abBpj2VU8p6qlRzTU8o22q68MmOaZ4v8zZ4UlYl5YRU=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "8d5e27b4807d25308dfe369d5a923d87e7dbfda3", "type": "github" }, "original": { @@ -50,13 +71,29 @@ "type": "github" } }, - "nixpkgs": { + "nixpkgs-stable": { "locked": { - "lastModified": 1717602782, - "narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=", + "lastModified": 1718208800, + "narHash": "sha256-US1tAChvPxT52RV8GksWZS415tTS7PV42KTc2PNDBmc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6", + "rev": "cc54fb41d13736e92229c21627ea4f22199fee6b", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1718318537, + "narHash": "sha256-4Zu0RYRcAY/VWuu6awwq4opuiD//ahpc2aFHg2CWqFY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e9ee548d90ff586a6471b4ae80ae9cfcbceb3420", "type": "github" }, "original": { @@ -70,8 +107,10 @@ "inputs": { "currentSystem": "currentSystem", "flake-utils": "flake-utils", - "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "home-manager-stable": "home-manager-stable", + "home-manager-unstable": "home-manager-unstable", + "nixpkgs-stable": "nixpkgs-stable", + "nixpkgs-unstable": "nixpkgs-unstable" } }, "systems": { diff --git a/flake.nix b/flake.nix index f071b9f..a22692d 100644 --- a/flake.nix +++ b/flake.nix @@ -4,15 +4,28 @@ inputs = { currentSystem.url = "path:/etc/nixos/hostname"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05"; - home-manager.url = "github:nix-community/home-manager"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + + home-manager-stable.url = "github:nix-community/home-manager/release-24.05"; + home-manager-stable.inputs.nixpkgs.follows = "nixpkgs-stable"; + + home-manager-unstable.url = "github:nix-community/home-manager"; + home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; - outputs = inputs@{ self, currentSystem, nixpkgs, home-manager, flake-utils, ... }: let + outputs = inputs@{ self + , currentSystem + , nixpkgs-stable + , nixpkgs-unstable + , home-manager-stable + , home-manager-unstable + , flake-utils + , ... + }: let inherit (self) outputs; inherit (currentSystem) hostname; @@ -21,6 +34,7 @@ configs."ankaa" = { system = "x86_64-linux"; + common.nixpkgs = "unstable"; openssh = { enable = true; @@ -95,6 +109,7 @@ configs."alpheratz" = { system = "x86_64-linux"; + common.nixpkgs = "unstable"; audio = { pipewire.enable = true; @@ -127,15 +142,35 @@ }; }; + currentConfig = configs."${hostname}"; + system = currentConfig.system; - configs."default-hostname" = {}; + nixpkgs = if currentConfig.common.nixpkgs == "unstable" then + nixpkgs-unstable + else + nixpkgs-stable; + + home-manager = if currentConfig.common.nixpkgs == "unstable" then + home-manager-unstable + else + home-manager-stable; - system = configs."${hostname}".system; pkgs = import nixpkgs { - inherit system; - overlays = with overlays; [ gamescope ]; - config.allowUnfree = true; - }; + inherit system; + overlays = with overlays; [ gamescope ]; + config.allowUnfree = true; + }; + + + systemConfig = if builtins.pathExists (./. + "/hosts/${hostname}/system.nix") then + (./. + "/hosts/${hostname}/system.nix") + else + ./hosts/default/system.nix; + + homeConfig = if builtins.pathExists (./. + "/hosts/${hostname}/home.nix") then + (./. + "/hosts/${hostname}/home.nix") + else + ./hosts/default/home.nix; in { nixosConfigurations = { @@ -147,10 +182,10 @@ modules = [ { networking.hostName = hostname; - simmer = configs."${hostname}"; + simmer = currentConfig; } (import ./modules/nix) - (./. + "/hosts/${hostname}/system.nix") + systemConfig (./. + "/hosts/${hostname}/hardware-configuration.nix") home-manager.nixosModules.home-manager { @@ -161,7 +196,7 @@ systemConfig = configs."${hostname}"; }; - home-manager.users.eesim = import (./. + "/hosts/${hostname}/home.nix"); + home-manager.users.eesim = import homeConfig; } ]; }; diff --git a/hosts/alpheratz/system.nix b/hosts/alpheratz/system.nix index 0924abd..ebec6b4 100644 --- a/hosts/alpheratz/system.nix +++ b/hosts/alpheratz/system.nix @@ -65,7 +65,6 @@ users.users.eesim = { isNormalUser = true; extraGroups = [ "wheel" "video" "audo" "networkmanager" ]; - packages = with pkgs; []; shell = pkgs.fish; }; diff --git a/hosts/default/hardware-configuration.nix b/hosts/default/hardware-configuration.nix new file mode 100644 index 0000000..954266b --- /dev/null +++ b/hosts/default/hardware-configuration.nix @@ -0,0 +1,45 @@ +# 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 = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/ad45b094-608d-4850-b5ba-0f3917947629"; + fsType = "btrfs"; + options = [ "subvol=root" ]; + }; + + fileSystems."/home" = + { device = "/dev/disk/by-uuid/ad45b094-608d-4850-b5ba-0f3917947629"; + fsType = "btrfs"; + options = [ "subvol=home" ]; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-uuid/ad45b094-608d-4850-b5ba-0f3917947629"; + fsType = "btrfs"; + options = [ "subvol=nix" ]; + }; + + 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"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/default/home.nix b/hosts/default/home.nix new file mode 100644 index 0000000..d8fa011 --- /dev/null +++ b/hosts/default/home.nix @@ -0,0 +1,23 @@ +{ + config, + pkgs, + ... +}: +{ + + imports = [ + ../../modules/home + ]; + + home = { + username = "eesim"; + homeDirectory = "/home/eesim"; + }; + + home.file.".config/nvim".source = ../shared/dotfiles/nvim; + home.file.".tmux.conf".source = ../shared/dotfiles/tmux; + + programs.home-manager.enable = true; + + home.stateVersion = "23.11"; +} diff --git a/hosts/default/system.nix b/hosts/default/system.nix new file mode 100644 index 0000000..85c73ee --- /dev/null +++ b/hosts/default/system.nix @@ -0,0 +1,39 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ + lib, + config, + pkgs, + ... +}: { + nix = { + settings = { + experimental-features = "nix-command flakes"; + }; + }; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Set your time zone. + time.timeZone = "America/Chicago"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + # Define a user account. + users.users.eesim = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; + + # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, + # and migrated your data accordingly. + # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + system.stateVersion = "23.11"; # Did you read the comment? + +} + diff --git a/main.log b/main.log deleted file mode 100644 index 5acced9..0000000 --- a/main.log +++ /dev/null @@ -1,11 +0,0 @@ -[1717810556] Log start -[1717810556] Cmd: llama -[1717810556] main: build = 0 (unknown) -[1717810556] main: built with gcc (GCC) 13.2.0 for x86_64-unknown-linux-gnu -[1717810556] main: seed = 1717810556 -[1717810556] main: llama backend init -[1717810556] main: load the model and apply lora adapter, if any -[1717810556] llama_model_load: error loading model: llama_model_loader: failed to load model from models/7B/ggml-model-f16.gguf - -[1717810556] llama_load_model_from_file: failed to load model -[1717810556] main: error: unable to load model diff --git a/modules/nix/common.nix b/modules/nix/common.nix index c75bb1f..f7d903f 100644 --- a/modules/nix/common.nix +++ b/modules/nix/common.nix @@ -34,6 +34,11 @@ in type = types.enum [ "ctrl-esc" "esc" "caps" ]; default = "ctrl-esc"; }; + + nixpkgs = mkOption { + description = "Which nixpkgs version to use"; + type = types.any; + }; }; diff --git a/modules/nix/networking.nix b/modules/nix/networking.nix index 9e50e0b..9440359 100644 --- a/modules/nix/networking.nix +++ b/modules/nix/networking.nix @@ -58,6 +58,7 @@ in config = { environment.systemPackages = with pkgs; [ ldns + mtr ] ++ optional cfg.wireguard.enable wireguard-tools; diff --git a/overlays/llama-cpp.nix b/overlays/llama-cpp.nix deleted file mode 100644 index 8971cc1..0000000 --- a/overlays/llama-cpp.nix +++ /dev/null @@ -1,6 +0,0 @@ -{}: -{ - final: prev: { - llama-cpp = ; - } -}