diff --git a/nix/os/devices/odroidh2p-0/README.md b/nix/os/devices/odroidh2p-0/README.md new file mode 100644 index 0000000..8ed679d --- /dev/null +++ b/nix/os/devices/odroidh2p-0/README.md @@ -0,0 +1,37 @@ +# Manual installation - unencrypted + +## Partitioning +``` +mkpart bios_grub 1MiB 2MiB +set 1 bios_grub on +mkpart bios 2MiB 512MiB +set 2 esp on +mkpart pv 512MiB 100% +``` + +## LVM +``` +pvcreate /dev/mmcblk0p3 +vgcreate odroidh2p-0 /dev/mmcblk0p3 +lvcreate -L 1g -n swap odroidh2p-0 +lvcreate -L 32G -n nixos odroidh2p-0 +``` + +## Filesystems + +``` +mkfs.fat -F 32 -n boot /dev/mmcblk0p2 +mkfs.btrfs /dev/odroidh2p-0/nixos +mkswap /dev/odroidh2p-0/swap +# subvolume for rootfs and home +# mount at /mnt/nixos +mkdir -p /mnt/nixos/etc/boot/ +``` + +## NixOS install + +FIXME: why was this necessary? +``` +mkdir -p /mnt/nixos/etc/nixos/ +touch /mnt/nixos/etc/nixos/configuration.nix +``` diff --git a/nix/os/devices/odroidh2p-0/boot.nix b/nix/os/devices/odroidh2p-0/boot.nix new file mode 100644 index 0000000..2cb19ca --- /dev/null +++ b/nix/os/devices/odroidh2p-0/boot.nix @@ -0,0 +1,10 @@ +{ lib +, config +, ... +}: + +{ + boot.extraModulePackages = [ + config.boot.kernelPackages.r8125 + ]; +} diff --git a/nix/os/devices/odroidh2p-0/configuration.nix b/nix/os/devices/odroidh2p-0/configuration.nix new file mode 100644 index 0000000..626c5f1 --- /dev/null +++ b/nix/os/devices/odroidh2p-0/configuration.nix @@ -0,0 +1,14 @@ +{ ... }: + +{ + disabledModules = [ + ]; + imports = [ + ../../profiles/common/configuration.nix + + ./system.nix + ./hw.nix + ./pkg.nix + ./boot.nix + ]; +} diff --git a/nix/os/devices/odroidh2p-0/hw.nix b/nix/os/devices/odroidh2p-0/hw.nix new file mode 100644 index 0000000..bb12514 --- /dev/null +++ b/nix/os/devices/odroidh2p-0/hw.nix @@ -0,0 +1,71 @@ +{ ... }: + +let + stage1Modules = [ + # "aesni_intel" + # "kvm-intel" + "aes_x86_64" + + "mmc_block" + "mmc_core" + "sdhci_pci" + "sdhci" + "cqhci" + "mii" + "usbnet" + "ax88179_178a" + "libphy" + "libata" + "libahci" + "usbcore" + "xhci_hcd" + "scsi_mod" + + + "fat" + "vfat" + "i915" + "mei_me" + "ahci" + "xhci_pci" + "intel_lpss_pci" + "intel_lpss_pci" + "intel_lpss_pci" + "intel_lpss_pci" + "sdhci_pci" + "i2c_i801" + "r8169" + ]; + +in +{ + fileSystems."/boot" = { + device = "/dev/mmcblk0p2"; + fsType = "vfat"; + }; + + fileSystems."/" = { + device = "/dev/odroidh2p-0/nixos"; + fsType = "btrfs"; + options = [ "subvol=rootfs" ]; + neededForBoot = true; + }; + + fileSystems."/home" = { + device = "/dev/odroidh2p-0/nixos"; + fsType = "btrfs"; + options = [ "subvol=home" ]; + neededForBoot = true; + }; + + swapDevices = [ { device = "/dev/odroidh2p-0/swap"; } ]; + + boot.loader.grub = { + device = "/dev/mmcblk0"; + }; + + boot.initrd.availableKernelModules = stage1Modules; + boot.initrd.kernelModules = stage1Modules; + boot.extraModprobeConfig = '' + ''; +} diff --git a/nix/os/devices/odroidh2p-0/pkg.nix b/nix/os/devices/odroidh2p-0/pkg.nix new file mode 100644 index 0000000..bad7478 --- /dev/null +++ b/nix/os/devices/odroidh2p-0/pkg.nix @@ -0,0 +1,30 @@ +{ config +, pkgs +, lib +, ... +}: + +{ + nixpkgs.config.packageOverrides = pkgs: with pkgs; { + nixPath = (import ../../../default.nix { versionsPath = ./versions.nix; }).nixPath; + }; + home-manager.users.steveej = import ../../../home-manager/configuration/text-minimal.nix { + inherit pkgs; + extraPackages = [ + # required by vscode's remote-ssh plugin + pkgs.nodejs + + # allow clipboard exchanges + pkgs.xsel + pkgs.xclip + ]; + }; + + nix.buildMachines = [ + { hostName = "localhost"; + system = "x86_64-linux"; + supportedFeatures = ["kvm" "nixos-test" "big-parallel" "benchmark"]; + maxJobs = 4; + } + ]; +} diff --git a/nix/os/devices/odroidh2p-0/system.nix b/nix/os/devices/odroidh2p-0/system.nix new file mode 100644 index 0000000..325cc7f --- /dev/null +++ b/nix/os/devices/odroidh2p-0/system.nix @@ -0,0 +1,59 @@ +{ pkgs +, lib +, config +, ... }: + +let + keys = import ../../../variables/keys.nix; + +in { + # TASK: new device + networking.hostName = "odroidh2p-0"; # Define your hostname. + # networking.domain = ""; + + networking.firewall.enable = true; + networking.firewall.allowedTCPPorts = [ + # iperf3 + 5201 + ]; + networking.firewall.logRefusedConnections = false; + + networking.usePredictableInterfaceNames = false; + + networking.useDHCP = false; + + networking.interfaces.eth0 = { + useDHCP = true; + }; + + networking.interfaces.eth1 = { + useDHCP = false; + }; + + networking.nat = { + enable = true; + internalInterfaces = [ "ve-+" ]; + externalInterface = "eth0"; + }; + + # virtualization + virtualisation = { + docker.enable = true; + }; + + nix.gc = { + automatic = true; + }; + + networking.useHostResolvConf = true; + + services.openssh.forwardX11 = 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 = "20.09"; # Did you read the comment? +} diff --git a/nix/os/devices/odroidh2p-0/versions.nix b/nix/os/devices/odroidh2p-0/versions.nix new file mode 100644 index 0000000..519781a --- /dev/null +++ b/nix/os/devices/odroidh2p-0/versions.nix @@ -0,0 +1,37 @@ +let + nixpkgs = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "nixos-20.09"; + rev = "51aaa3fa1b69559456f9bd4968bd5b179a784f67"; + }; +in + +{ + inherit nixpkgs; + "channels-nixos-stable" = nixpkgs; + "channels-nixos-20.03" = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "nixos-20.03"; + rev = "ff6fda61600cc60404bab5cb6b18b8636785b7bc"; + }; + "channels-nixos-19.09" = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "nixos-19.09"; + rev = "75f4ba05c63be3f147bcc2f7bd4ba1f029cedcb1"; + }; + "channels-nixos-unstable" = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "nixos-unstable"; + rev = "24c9b05ac53e422f1af81a156f1fd58499eb27fb"; + }; + "nixpkgs-master" = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "master"; + rev = "9b3e35d991ea6a43f256069dcb2e006006730d05"; + }; + "home-manager-module" = { + url = "https://github.com/nix-community/home-manager"; + ref = "release-20.09"; + rev = "7339784e07217ed0232e08d1ea33b610c94657d8"; + }; +} diff --git a/nix/os/devices/odroidh2p-0/versions.tmpl.nix b/nix/os/devices/odroidh2p-0/versions.tmpl.nix new file mode 100644 index 0000000..a19cc09 --- /dev/null +++ b/nix/os/devices/odroidh2p-0/versions.tmpl.nix @@ -0,0 +1,37 @@ +let + nixpkgs = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "nixos-20.09"; + rev = "<% git ls-remote https://github.com/nixos/nixpkgs nixos-20.09 | awk '{ print $1 }' | tr -d '\n' -%>"; + }; +in + +{ + inherit nixpkgs; + "channels-nixos-stable" = nixpkgs; + "channels-nixos-20.03" = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "nixos-20.03"; + rev = "<% git ls-remote https://github.com/nixos/nixpkgs nixos-20.03 | awk '{ print $1 }' | tr -d '\n' -%>"; + }; + "channels-nixos-19.09" = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "nixos-19.09"; + rev = "<% git ls-remote https://github.com/nixos/nixpkgs nixos-19.09 | awk '{ print $1 }' | tr -d '\n' -%>"; + }; + "channels-nixos-unstable" = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "nixos-unstable"; + rev = "<% git ls-remote https://github.com/nixos/nixpkgs nixos-unstable | awk '{ print $1 }' | tr -d '\n' -%>"; + }; + "nixpkgs-master" = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "master"; + rev = "<% git ls-remote https://github.com/NixOS/nixpkgs.git master | head -n1 | awk '{ print $1 }' | tr -d '\n' -%>"; + }; + "home-manager-module" = { + url = "https://github.com/nix-community/home-manager"; + ref = "release-20.09"; + rev = "<% git ls-remote https://github.com/nix-community/home-manager.git release-20.09 | awk '{ print $1 }' | tr -d '\n' -%>"; + }; +} diff --git a/shell.nix b/shell.nix index b8ce6da..c8557d3 100644 --- a/shell.nix +++ b/shell.nix @@ -26,6 +26,7 @@ stdenv.mkDerivation { nmap sysstat lshw + vim ]; # Set Environment Variables