diff --git a/lib/default.nix b/backup/lib/default.nix similarity index 100% rename from lib/default.nix rename to backup/lib/default.nix diff --git a/lib/host.nix b/backup/lib/host.nix similarity index 100% rename from lib/host.nix rename to backup/lib/host.nix diff --git a/lib/user.nix b/backup/lib/user.nix similarity index 100% rename from lib/user.nix rename to backup/lib/user.nix diff --git a/modules/system/boot/default.nix b/backup/modules/system/boot/default.nix similarity index 100% rename from modules/system/boot/default.nix rename to backup/modules/system/boot/default.nix diff --git a/modules/system/core/default.nix b/backup/modules/system/core/default.nix similarity index 100% rename from modules/system/core/default.nix rename to backup/modules/system/core/default.nix diff --git a/modules/system/default.nix b/backup/modules/system/default.nix similarity index 100% rename from modules/system/default.nix rename to backup/modules/system/default.nix diff --git a/modules/system/nixos/default.nix b/backup/modules/system/nixos/default.nix similarity index 100% rename from modules/system/nixos/default.nix rename to backup/modules/system/nixos/default.nix diff --git a/modules/users/applications/alacritty.nix b/backup/modules/users/applications/alacritty.nix similarity index 100% rename from modules/users/applications/alacritty.nix rename to backup/modules/users/applications/alacritty.nix diff --git a/modules/users/applications/default.nix b/backup/modules/users/applications/default.nix similarity index 100% rename from modules/users/applications/default.nix rename to backup/modules/users/applications/default.nix diff --git a/modules/users/applications/firefox.nix b/backup/modules/users/applications/firefox.nix similarity index 100% rename from modules/users/applications/firefox.nix rename to backup/modules/users/applications/firefox.nix diff --git a/modules/users/applications/rofi.nix b/backup/modules/users/applications/rofi.nix similarity index 100% rename from modules/users/applications/rofi.nix rename to backup/modules/users/applications/rofi.nix diff --git a/modules/users/default.nix b/backup/modules/users/default.nix similarity index 100% rename from modules/users/default.nix rename to backup/modules/users/default.nix diff --git a/modules/users/fish/default.nix b/backup/modules/users/fish/default.nix similarity index 100% rename from modules/users/fish/default.nix rename to backup/modules/users/fish/default.nix diff --git a/modules/users/git/default.nix b/backup/modules/users/git/default.nix similarity index 100% rename from modules/users/git/default.nix rename to backup/modules/users/git/default.nix diff --git a/modules/users/gpg/default.nix b/backup/modules/users/gpg/default.nix similarity index 100% rename from modules/users/gpg/default.nix rename to backup/modules/users/gpg/default.nix diff --git a/modules/users/input/default.nix b/backup/modules/users/input/default.nix similarity index 100% rename from modules/users/input/default.nix rename to backup/modules/users/input/default.nix diff --git a/modules/users/ssh/default.nix b/backup/modules/users/ssh/default.nix similarity index 100% rename from modules/users/ssh/default.nix rename to backup/modules/users/ssh/default.nix diff --git a/modules/users/sway/default.nix b/backup/modules/users/sway/default.nix similarity index 100% rename from modules/users/sway/default.nix rename to backup/modules/users/sway/default.nix diff --git a/modules/users/sway/sway.nix b/backup/modules/users/sway/sway.nix similarity index 100% rename from modules/users/sway/sway.nix rename to backup/modules/users/sway/sway.nix diff --git a/modules/users/sway/wallpapers/river-1920.png b/backup/modules/users/sway/wallpapers/river-1920.png similarity index 100% rename from modules/users/sway/wallpapers/river-1920.png rename to backup/modules/users/sway/wallpapers/river-1920.png diff --git a/modules/users/sway/wallpapers/river-2560.png b/backup/modules/users/sway/wallpapers/river-2560.png similarity index 100% rename from modules/users/sway/wallpapers/river-2560.png rename to backup/modules/users/sway/wallpapers/river-2560.png diff --git a/modules/users/sway/waybar.nix b/backup/modules/users/sway/waybar.nix similarity index 100% rename from modules/users/sway/waybar.nix rename to backup/modules/users/sway/waybar.nix diff --git a/flake.nix b/flake.nix index 93e51ab..8416dcb 100644 --- a/flake.nix +++ b/flake.nix @@ -2,125 +2,150 @@ description = "System config"; inputs = { - nixpkgs.url = "nixpkgs/nixos-unstable"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-21.05"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + + flake-utils.url = "github:numtide/flake-utils"; + + }; outputs = { nixpkgs, home-manager, ... }@inputs: let - inherit (nixpkgs) lib; - util = import ./lib { - inherit system pkgs home-manager lib; - overlays = (pkgs.overlays); - }; + defSystem = systemArch: baseConfig: + nixpkgs.lib.nixosSystem { + system = "${systemArch}"; + modules = [ + { _module.args.inputs = inputs; } + { _module.args.self-overlay = self.overlay; } + { _module.args.overlay-unstable = self.overlay-unstable; } + ({ ... }: { + imports = builtins.attrValues self.nixosModules ++ [ + { + nix.nixPath = [ "nixpkgs=${nixpkgs}" ]; + nixpkgs.overlays = [ self.overlay self.overlay-unstable ]; + } - inherit (util) user; - inherit (util) host; + baseConfig + home-manager.nixosModules.home-manager + { home-manager.useUserPackages = true; } + ]; - inherit (import ./pkgs { - inherit pkgs; - }) myPkgs; - - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - overlays = [ ]; - }; - - system = "x86_64-linux"; - - vm1BiosConfig = { - boot = { - type = "bios"; - qemu = true; - grubInstallDevice = "/dev/vda"; + system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; + nix.registry.nixpkgs.flake = nixpkgs; + }) + ]; }; - core.enable = true; - }; - vm1UefiConfig = { - boot = { - type = "uefi"; - qemu = true; - }; - core.enable = true; - }; - - vm2Config = { - boot = { - type = "uefi"; - qemu = true; - }; - core.enable = true; - }; - - nixosUsers = [{ - name = "erwin"; - groups = [ "wheel" "networkmanager" "video" ]; - uid = 1000; - shell = pkgs.fish; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMNoTcRsAxDwpiIj6nhUXwzSQjtcgKCR0RDlzP57wi0W erwin@horusvr-ws2" - ]; - }]; + # nixosUsers = [{ + # name = "erwin"; + # groups = [ "wheel" "networkmanager" "video" ]; + # uid = 1000; + # shell = pkgs.fish; + # openssh.authorizedKeys.keys = [ + # "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMNoTcRsAxDwpiIj6nhUXwzSQjtcgKCR0RDlzP57wi0W erwin@horusvr-ws2" + # ]; + # }]; in { - homeManagerConfigurations = { - erwin = user.mkHMUser { - userConfig = { - git.enable = true; - ssh.enable = true; - applications.enable = true; - gpg.enable = true; - fish.enable = true; - sway.enable = true; - }; - username = "erwin"; + # homeManagerConfigurations = { + # erwin = user.mkHMUser { + # userConfig = { + # git.enable = true; + # ssh.enable = true; + # applications.enable = true; + # gpg.enable = true; + # fish.enable = true; + # sway.enable = true; + # }; + # username = "erwin"; + # }; + # }; + + overlay = final: prev: (import ./overlays) final prev; + overlay-unstable = final: prev: { + unstable = import nixpkgs-unstable { + system = "x86_64-linux"; + config.allowUnfree = true; }; }; + nixosModules = builtins.listToAttrs (map + (x: { + name = x; + value = import (./modules + "/${x}"); + }) + (builtins.attrNames (builtins.readDir ./modules))); + nixosConfigurations = { - vm1 = host.mkHost { - name = "vm1"; - NICs = [ "enp1s0" ]; - kernelPackage = pkgs.linuxPackages; - initrdMods = [ "ahci" "xhci_pci" "sr_mod" ]; - kernelMods = [ "kvm-amd" ]; - kernelParams = [ ]; - systemConfig = vm1UefiConfig; - - users = nixosUsers; - - cpuCores = 6; - }; - - vm2 = host.mkHost { - name = "vm2"; - NICs = [ "enp1s0" ]; - kernelPackage = pkgs.linuxPackages; - initrdMods = [ "ahci" "xhci_pci" "sr_mod" ]; - kernelMods = [ "kvm-amd" ]; - kernelParams = [ ]; - systemConfig = vm2Config; - - users = nixosUsers; - - cpuCores = 4; - }; - - # loki = host.mkHost { - # name = "loki"; - # NICs = [ "enp4s0" ]; + # vm1 = host.mkHost { + # name = "vm1"; + # NICs = [ "enp1s0" ]; # kernelPackage = pkgs.linuxPackages; - # initrdMods = [ "nvme" "xhci_pci" "ahci" ]; + # initrdMods = [ "ahci" "xhci_pci" "sr_mod" ]; # kernelMods = [ "kvm-amd" ]; + # kernelParams = [ ]; + # systemConfig = vm1UefiConfig; + + # users = nixosUsers; + + # cpuCores = 6; # }; + + # vm2 = host.mkHost { + # name = "vm2"; + # NICs = [ "enp1s0" ]; + # kernelPackage = pkgs.linuxPackages; + # initrdMods = [ "ahci" "xhci_pci" "sr_mod" ]; + # kernelMods = [ "kvm-amd" ]; + # kernelParams = [ ]; + # systemConfig = vm2Config; + + # users = nixosUsers; + + # cpuCores = 4; + # }; + vm2 = defSystem "x86_64-linux" { + imports = [ + (import (./machines/vm2/configuration.nix) { inherit self; }) + ]; + }; + + # loki = defSystem "x86_64-linux" { + # imports = [ + # (import (./machines/loki/configuration.nix) { inherit self; }) + # ]; + # }; + }; - }; + } + (flake-utils.lib.eachSystem [ "x86_64-linux" ]) + (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + config = { + allowUnsupportedSystem = true; + allowUnfree = true; + }; + }; + in + rec { + packages = flake-utils.lib.flattenTree { + rofi-wayland = pkgs.rofi-wayland; + }; + + apps = { + rofi-wayland = flake-utils.lib.mkApp { drv = packages.rofi-wayland; }; + }; + } + ); } diff --git a/machines/vm2/configuration.nix b/machines/vm2/configuration.nix new file mode 100644 index 0000000..7587313 --- /dev/null +++ b/machines/vm2/configuration.nix @@ -0,0 +1,31 @@ +{ self, ... }: +{ + imports = [ ./hardware-configuration.nix ../../users/erwin.nix ]; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + time.timeZone = "Europe/Amsterdam"; + + networking = { + hostname = "vm2"; + useDHCP = false; + interfaces.enp1s.useDHCP = true; + }; + + nix = { + package = pkgs.nixUnstable; + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + + services.openssh.enable = 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 = "21.05"; # Did you read the comment? +} diff --git a/machines/vm2/hardware-configuration.nix b/machines/vm2/hardware-configuration.nix new file mode 100644 index 0000000..dc456b4 --- /dev/null +++ b/machines/vm2/hardware-configuration.nix @@ -0,0 +1,32 @@ +# 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 + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { + device = "/dev/disk/by-label/boot"; + fsType = "vfat"; + }; + + swapDevices = + [{ device = "/dev/disk/by-label/swap"; }]; + +} diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..e71f99d --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,3 @@ +self: super: { + rofi-wayland = super.pkgs.callPackage ../pkgs/rofi-wayland { }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix deleted file mode 100644 index 998217b..0000000 --- a/pkgs/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs, ... }: -with pkgs; -{ - myPkgs = { - rofi-wayland = callPackage ./rofi-wayland.nix { }; - }; -} diff --git a/pkgs/rofi-wayland.nix b/pkgs/rofi-wayland/default.nix similarity index 100% rename from pkgs/rofi-wayland.nix rename to pkgs/rofi-wayland/default.nix diff --git a/users/erwin.nix b/users/erwin.nix new file mode 100644 index 0000000..9970cf4 --- /dev/null +++ b/users/erwin.nix @@ -0,0 +1,17 @@ +{ config, pkgs, lib, ... }: +{ + users.users.erwin = { + isNormalUser = true; + home = "/home/erwin"; + exdraGroups = [ "wheel" "adm" "audio" "video" ]; + shell = pkgs.fish; + openssh.authorizedKeys.keyFiles = [ + (pkgs.fetchurl { + url = "https://github.com/eboskma.keys"; + sha256 = "1l7f425kvfmrs4dfcvllb76182jgb14l1silyy4qmjxvinawb1yj"; + }) + ]; + }; + + nix.allowedUsers = [ "erwin" ]; +}