Initial rewrite

This commit is contained in:
Erwin Boskma 2021-11-12 07:23:46 +01:00
parent 3fd137aad3
commit f161e02f36
Signed by: erwin
GPG key ID: B4F4B090E4BD95A9
29 changed files with 204 additions and 103 deletions

View file

Before

Width:  |  Height:  |  Size: 2.8 MiB

After

Width:  |  Height:  |  Size: 2.8 MiB

View file

Before

Width:  |  Height:  |  Size: 4.8 MiB

After

Width:  |  Height:  |  Size: 4.8 MiB

217
flake.nix
View file

@ -2,125 +2,150 @@
description = "System config"; description = "System config";
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-21.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { nixpkgs, home-manager, ... }@inputs: outputs = { nixpkgs, home-manager, ... }@inputs:
let let
inherit (nixpkgs) lib;
util = import ./lib { defSystem = systemArch: baseConfig:
inherit system pkgs home-manager lib; nixpkgs.lib.nixosSystem {
overlays = (pkgs.overlays); 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; baseConfig
inherit (util) host; home-manager.nixosModules.home-manager
{ home-manager.useUserPackages = true; }
];
inherit (import ./pkgs { system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
inherit pkgs; nix.registry.nixpkgs.flake = nixpkgs;
}) myPkgs; })
];
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ ];
};
system = "x86_64-linux";
vm1BiosConfig = {
boot = {
type = "bios";
qemu = true;
grubInstallDevice = "/dev/vda";
}; };
core.enable = true;
};
vm1UefiConfig = { # nixosUsers = [{
boot = { # name = "erwin";
type = "uefi"; # groups = [ "wheel" "networkmanager" "video" ];
qemu = true; # uid = 1000;
}; # shell = pkgs.fish;
core.enable = true; # openssh.authorizedKeys.keys = [
}; # "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMNoTcRsAxDwpiIj6nhUXwzSQjtcgKCR0RDlzP57wi0W erwin@horusvr-ws2"
# ];
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"
];
}];
in in
{ {
homeManagerConfigurations = { # homeManagerConfigurations = {
erwin = user.mkHMUser { # erwin = user.mkHMUser {
userConfig = { # userConfig = {
git.enable = true; # git.enable = true;
ssh.enable = true; # ssh.enable = true;
applications.enable = true; # applications.enable = true;
gpg.enable = true; # gpg.enable = true;
fish.enable = true; # fish.enable = true;
sway.enable = true; # sway.enable = true;
}; # };
username = "erwin"; # 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 = { nixosConfigurations = {
vm1 = host.mkHost { # vm1 = host.mkHost {
name = "vm1"; # name = "vm1";
NICs = [ "enp1s0" ]; # 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" ];
# kernelPackage = pkgs.linuxPackages; # kernelPackage = pkgs.linuxPackages;
# initrdMods = [ "nvme" "xhci_pci" "ahci" ]; # initrdMods = [ "ahci" "xhci_pci" "sr_mod" ];
# kernelMods = [ "kvm-amd" ]; # 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; };
};
}
);
} }

View file

@ -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. Its 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?
}

View file

@ -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"; }];
}

3
overlays/default.nix Normal file
View file

@ -0,0 +1,3 @@
self: super: {
rofi-wayland = super.pkgs.callPackage ../pkgs/rofi-wayland { };
}

View file

@ -1,7 +0,0 @@
{ pkgs, ... }:
with pkgs;
{
myPkgs = {
rofi-wayland = callPackage ./rofi-wayland.nix { };
};
}

17
users/erwin.nix Normal file
View file

@ -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" ];
}