From b0cfcb6c8d8cc12add6419a2838c92ec9a46a141 Mon Sep 17 00:00:00 2001 From: Gabe Venberg Date: Fri, 24 May 2024 15:23:56 -0500 Subject: [PATCH] start of a latepanda config. --- .envrc | 1 + .gitignore | 2 +- flake.lock | 104 ++++++++++++++++----------- flake.nix | 25 ++++++- hosts/archlaptop-vm/default.nix | 3 - hosts/nfs-panda/default.nix | 122 ++++++++++++++++++++++++++++++++ hosts/nfs-panda/disk-config.nix | 74 +++++++++++++++++++ justfile | 2 +- 8 files changed, 284 insertions(+), 49 deletions(-) create mode 100644 .envrc create mode 100644 hosts/nfs-panda/default.nix create mode 100644 hosts/nfs-panda/disk-config.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index a806510..7cb17a5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ # Ignore build outputs from performing a nix-build or `nix build` command result result-* - +.direnv diff --git a/flake.lock b/flake.lock index 35887c5..7c1cbd4 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,31 @@ { "nodes": { + "deploy-rs": { + "inputs": { + "flake-compat": [ + "flake-compat" + ], + "nixpkgs": [ + "nixpkgs" + ], + "utils": [ + "flake-utils" + ] + }, + "locked": { + "lastModified": 1715699772, + "narHash": "sha256-sKhqIgucN5sI/7UQgBwsonzR4fONjfMr9OcHK/vPits=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "b3ea6f333f9057b77efd9091119ba67089399ced", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, "devshell": { "inputs": { "flake-utils": "flake-utils_2", @@ -22,8 +48,27 @@ "type": "github" } }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1716431128, + "narHash": "sha256-t3T8HlX3udO6f4ilLcN+j5eC3m2gqsouzSGiriKK6vk=", + "owner": "nix-community", + "repo": "disko", + "rev": "7ffc4354dfeb37c8c725ae1465f04a9b45ec8606", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "flake-compat": { - "flake": false, "locked": { "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", @@ -39,20 +84,6 @@ } }, "flake-compat_2": { - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "revCount": 57, - "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" - } - }, - "flake-compat_3": { "flake": false, "locked": { "lastModified": 1696426674, @@ -185,27 +216,6 @@ "type": "github" } }, - "home-manager_2": { - "inputs": { - "nixpkgs": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1713732794, - "narHash": "sha256-AYCofb8Zu4Mbc1lHDtju/uxeARawRijmOueAqEMEfMU=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "670d9ecc3e46a6e3265c203c2d136031a3d3548e", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "home-manager", - "type": "github" - } - }, "nix-darwin": { "inputs": { "nixpkgs": [ @@ -229,8 +239,12 @@ }, "nixos-wsl": { "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", + "flake-compat": [ + "flake-compat" + ], + "flake-utils": [ + "flake-utils" + ], "nixpkgs": [ "nixpkgs" ] @@ -269,9 +283,13 @@ "nixvim": { "inputs": { "devshell": "devshell", - "flake-compat": "flake-compat_2", + "flake-compat": [ + "flake-compat" + ], "flake-parts": "flake-parts", - "home-manager": "home-manager_2", + "home-manager": [ + "home-manager" + ], "nix-darwin": "nix-darwin", "nixpkgs": [ "nixpkgs" @@ -294,7 +312,7 @@ }, "pre-commit-hooks": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_2", "flake-utils": "flake-utils_3", "gitignore": "gitignore", "nixpkgs": [ @@ -322,6 +340,10 @@ }, "root": { "inputs": { + "deploy-rs": "deploy-rs", + "disko": "disko", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", "home-manager": "home-manager", "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index 180c1a6..5537d53 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,8 @@ nixos-wsl = { url = "github:nix-community/NixOS-WSL/main"; inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + inputs.flake-compat.follows = "flake-compat"; }; home-manager = { @@ -18,14 +20,30 @@ nixvim = { url = "github:nix-community/nixvim"; inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-compat.follows = "flake-compat"; + inputs.home-manager.follows="home-manager"; }; + + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + deploy-rs = { + url = "github:serokell/deploy-rs"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.utils.follows = "flake-utils"; + inputs.flake-compat.follows = "flake-compat"; + }; + +# just for follows statements + flake-utils.url = "github:numtide/flake-utils"; + flake-compat.url="github:edolstra/flake-compat"; }; outputs = { self, nixpkgs, - home-manager, - nixvim, ... } @ inputs: let inherit (self) outputs; @@ -54,6 +72,7 @@ archlaptop-vm = import ./hosts/archlaptop-vm {inherit inputs outputs;}; workstation-vm = import ./hosts/workstation-vm {inherit inputs outputs;}; gv-wsl = import ./hosts/wsl-workstation.nix {inherit inputs outputs;}; + gv-nfs-panda = import ./hosts/nfs-panda {inherit inputs outputs;}; }; # Standalone home-manager configuration entrypoint @@ -65,6 +84,6 @@ "gabe@gv-ubuntu" = import ./hosts/home-workstation.nix {inherit inputs outputs;}; }; - templates=import ./templates {inherit inputs outputs;}; + templates = import ./templates {inherit inputs outputs;}; }; } diff --git a/hosts/archlaptop-vm/default.nix b/hosts/archlaptop-vm/default.nix index 28e0c02..5a1e31d 100644 --- a/hosts/archlaptop-vm/default.nix +++ b/hosts/archlaptop-vm/default.nix @@ -1,6 +1,3 @@ -# 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’). { inputs, outputs, diff --git a/hosts/nfs-panda/default.nix b/hosts/nfs-panda/default.nix new file mode 100644 index 0000000..e6bcc03 --- /dev/null +++ b/hosts/nfs-panda/default.nix @@ -0,0 +1,122 @@ +{ + inputs, + outputs, + ... +}: +inputs.nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = {inherit inputs outputs;}; + # > Our main nixos configuration file < + modules = [ + inputs.home-manager.nixosModules.home-manager + inputs.disko.nixosModules.disko + ./disk-config.nix + ../../modules/hostopts.nix + ../../modules/nixos/common.nix + ../../modules/nixos/networking.nix + ../../modules/nixos/nfsv2.nix + ({ + config, + pkgs, + ... + }: { + host = { + user = "gabe"; + gui.enable = false; + }; + networking.hostId = "4dabfd52"; + # Define your hostname. + networking.hostName = "gv-panda"; + systemd.network = { + enable = true; + networks = { + enp2s0 = { + name = "enp2s0"; + address = [ + "172.16.0.20/16" + "192.168.168.20/24" + ]; + }; + enx00249b6f0f57 = { + name = "enx00249b6f0f57"; + DHCP = "yes"; + }; + }; + }; + + time.timeZone = "America/Chicago"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + services.nfs.server = { + enable = true; + exports = "/srv/nfs *(rw,sync,no_root_squash)"; + createMountPoints = true; + }; + + environment.systemPackages = with pkgs; [ + zfs + neovim + ]; + + programs.zsh.enable = true; + environment.shells = with pkgs; [zsh]; + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.${config.host.user} = { + isNormalUser = true; + description = "Gabe Venberg"; + shell = pkgs.zsh; + extraGroups = ["wheel"]; + }; + + home-manager.users.${config.host.user} = { + inputs, + osConfig, + ... + }: { + host = osConfig.host; + # machine specific options + home = { + nvim = { + enable-lsp = false; + enable-treesitter = false; + }; + git = { + profile = { + name = "Gabe Venberg"; + email = "gabevenberg@gmail.com"; + }; + workProfile = { + enable = true; + email = "venberggabe@johndeere.com"; + }; + }; + }; + imports = [ + ../../roles/home-manager/terminal.nix + ../../modules/home-manager/common.nix + inputs.nixvim.homeManagerModules.nixvim + ]; + }; + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; + boot.supportedFilesystems = {zfs = true;}; + boot.initrd.supportedFilesystems = {zfs = 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 = "23.11"; # Did you read the comment? + }) + ]; +} diff --git a/hosts/nfs-panda/disk-config.nix b/hosts/nfs-panda/disk-config.nix new file mode 100644 index 0000000..f2a309e --- /dev/null +++ b/hosts/nfs-panda/disk-config.nix @@ -0,0 +1,74 @@ +{ + disko.devices = { + disk = { + emmc = { + device = "/dev/mmcblk0"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "64M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + ssd = { + device = "/dev/nvme0n1"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + }; + zpool = { + zroot = { + type = "zpool"; + rootFsOptions = { + ashift = "12"; + compression = "zstd"; + mountpoint = "none"; + atime = "off"; + }; + datasets = { + root_fs = { + type = "zfs_fs"; + mountpoint = "/"; + options.mountpoint = "legacy"; + }; + nix_fs = { + type = "zfs_fs"; + mountpoint = "/nix"; + options.mountpoint = "legacy"; + }; + nfs_fs = { + type = "zfs_fs"; + mountpoint = "/srv/nfs"; + }; + }; + }; + }; + }; +} diff --git a/justfile b/justfile index a660c78..0dfdede 100644 --- a/justfile +++ b/justfile @@ -11,7 +11,7 @@ home-manager target=(`whoami`+"@"+`hostname`): check: git add -AN - nix flake check + nix flake check --keep-going bootstrap-home-manager target=(`whoami`+"@"+`hostname`): nix run --extra-experimental-features "nix-command flakes" --no-write-lock-file github:nix-community/home-manager/ -- --extra-experimental-features "nix-command flakes" --flake .#{{target}} switch