diff --git a/apps/default.nix b/apps/default.nix index 83ddbc9..02355ce 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -25,9 +25,6 @@ rec { # Re-encrypt secrets for all machines reencrypt-secrets = import ./reencrypt-secrets.nix { inherit pkgs; }; - # Connect machine metrics to Netdata Cloud - netdata = import ./netdata-cloud.nix { inherit pkgs; }; - # Run neovim as an app neovim = import ./neovim.nix { inherit pkgs; }; nvim = neovim; diff --git a/apps/format-root.nix b/apps/format-root.nix index d844505..3859dc0 100644 --- a/apps/format-root.nix +++ b/apps/format-root.nix @@ -5,37 +5,5 @@ type = "app"; - program = builtins.toString ( - pkgs.writeShellScript "format-root" '' - set -e - - DISK=$1 - - if [ -z "''${DISK}" ]; then - ${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \ - --foreground "#fb4934" \ - "Missing required parameter." \ - "Usage: format-root -- " \ - "Flake example: nix run github:nmasur/dotfiles#format-root -- nvme0n1" - echo "(exiting)" - exit 1 - fi - - ${pkgs.disko}/bin/disko \ - --mode create \ - --dry-run \ - --flake "path:$(pwd)#root" \ - --arg disk \""/dev/''${DISK}"\" - - ${pkgs.gum}/bin/gum confirm \ - "This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \ - --default=false - - ${pkgs.disko}/bin/disko \ - --mode create \ - --flake "path:$(pwd)#root" \ - --arg disk "/dev/''${DISK}" - - '' - ); + program = pkgs.lib.getExe pkgs.format-root; } diff --git a/apps/help.nix b/apps/help.nix index 5ac7102..4f3e82f 100644 --- a/apps/help.nix +++ b/apps/help.nix @@ -17,7 +17,6 @@ ' • {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \ ' • {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \ ' • {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}' \ - ' • {{ Color "15" "57" " netdata " }} {{ Italic "Connect a machine to Netdata cloud." }}' echo "" echo "" '' diff --git a/apps/netdata-cloud.nix b/apps/netdata-cloud.nix deleted file mode 100644 index 9275df7..0000000 --- a/apps/netdata-cloud.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ pkgs, ... }: -{ - - type = "app"; - - program = builtins.toString ( - pkgs.writeShellScript "netdata-cloud" '' - if [ "$EUID" -ne 0 ]; then - echo "Please run as root" - exit 1 - fi - mkdir --parents --mode 0750 /var/lib/netdata/cloud.d - printf "\nEnter the claim token for netdata cloud...\n\n" - read -p "Token: " token - echo "''${token}" > /var/lib/netdata/cloud.d/token - chown -R netdata:netdata /var/lib/netdata - ${pkgs.netdata}/bin/netdata-claim.sh -id=$(uuidgen) - printf "\n\nNow restart netdata service.\n\n" - '' - ); -} diff --git a/disks/zfs.nix b/disks/zfs.nix deleted file mode 100644 index 3273a4e..0000000 --- a/disks/zfs.nix +++ /dev/null @@ -1,98 +0,0 @@ -{ pool, disks, ... }: -{ - disk = lib.genAttrs disks (disk: { - "${disk}" = { - type = "disk"; - device = "/dev/${disk}"; - content = { - type = "table"; - format = "gpt"; - partitions = [ - { - type = "partition"; - name = "zfs"; - start = "128MiB"; - end = "100%"; - content = { - type = "zfs"; - pool = pool; - }; - } - ]; - }; - }; - }); - zpool = { - "${pool}" = { - type = "zpool"; - mode = "raidz1"; - rootFsOptions = { - compression = "on"; # lz4 by default - "com.sun:auto-snapshot" = "false"; - ashift = "12"; - }; - # mountpoint = "/"; - - datasets = { - root = { - zfs_type = "filesystem"; - mountpoint = null; - options."com.sun:auto-snapshot" = "false"; - }; - # "media/movies" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/movies"; - # options.recordsize = "1M"; - # }; - # "media/tv" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/tv"; - # options.recordsize = "1M"; - # }; - # "media/books" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/books"; - # }; - # archive = { - # zfs_type = "filesystem"; - # mountpoint = "/archive"; - # options.compression = "zstd"; - # options."com.sun:auto-snapshot" = "true"; - # }; - # zfs_unmounted_fs = { - # zfs_type = "filesystem"; - # options.mountpoint = "none"; - # }; - # zfs_legacy_fs = { - # zfs_type = "filesystem"; - # options.mountpoint = "legacy"; - # mountpoint = "/zfs_legacy_fs"; - # }; - # zfs_testvolume = { - # zfs_type = "volume"; - # size = "10M"; - # content = { - # type = "filesystem"; - # format = "ext4"; - # mountpoint = "/ext4onzfs"; - # }; - # }; - # encrypted = { - # zfs_type = "filesystem"; - # size = "20M"; - # options = { - # mountpoint = "none"; - # encryption = "aes-256-gcm"; - # keyformat = "passphrase"; - # keylocation = "file:///tmp/secret.key"; - # }; - # }; - # "encrypted/test" = { - # zfs_type = "filesystem"; - # size = "2M"; - # mountpoint = "/zfs_crypted"; - # }; - }; - }; - }; -} diff --git a/flake.lock b/flake.lock index 8163ced..9263f36 100644 --- a/flake.lock +++ b/flake.lock @@ -508,26 +508,12 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1737062831, - "narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nur": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs_2", + "nixpkgs": [ + "nixpkgs" + ], "treefmt-nix": "treefmt-nix" }, "locked": { diff --git a/flake.nix b/flake.nix index 2b01609..35c9bd3 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "My system"; + description = "An opinionated flake containing the NixOS, nix-darwin, and home-manager configurations for multiple systems."; # Other flakes that we want to pull from inputs = { @@ -29,7 +29,10 @@ }; # Community packages; used for Firefox extensions - nur.url = "github:nix-community/nur"; + nur = { + url = "github:nix-community/nur"; + inputs.nixpkgs.follows = "nixpkgs"; + }; # Use official Firefox binary for macOS firefox-darwin = { diff --git a/modules/common/default.nix b/modules/common/default.nix index 8868ded..5827ee9 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -171,14 +171,6 @@ in { - # Basic common system packages for all devices - environment.systemPackages = with pkgs; [ - git - vim - wget - curl - ]; - # Allow specified unfree packages (identified elsewhere) # Retrieves package object based on string name nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.unfreePackages; diff --git a/pkgs/tools/misc/format-root/format-root.sh b/pkgs/tools/misc/format-root/format-root.sh new file mode 100755 index 0000000..6aabbbd --- /dev/null +++ b/pkgs/tools/misc/format-root/format-root.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -e + +DISK=$1 + +if [ -z "${DISK}" ]; then + gum style --width 50 --margin "1 2" --padding "2 4" \ + --foreground "#fb4934" \ + "Missing required parameter." \ + "Usage: format-root -- " \ + "Flake example: nix run github:nmasur/dotfiles#format-root -- nvme0n1" + echo "(exiting)" + exit 1 +fi + +disko \ + --mode create \ + --dry-run \ + --flake "path:$(pwd)#root" \ + --arg disk \""/dev/${DISK}"\" + +gum confirm \ + "This will ERASE ALL DATA on the disk /dev/${DISK}. Are you sure you want to continue?" \ + --default=false + +disko \ + --mode create \ + --flake "path:$(pwd)#root" \ + --arg disk "/dev/${DISK}" diff --git a/pkgs/tools/misc/format-root/package.nix b/pkgs/tools/misc/format-root/package.nix new file mode 100644 index 0000000..7f15c82 --- /dev/null +++ b/pkgs/tools/misc/format-root/package.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: + +pkgs.writeShellApplication { + name = "format-root"; + runtimeInputs = [ + pkgs.gum + pkgs.disko + ]; + text = builtins.readFile ./format-root.sh; +} diff --git a/platforms/home-manager/modules/nmasur/presets/programs/zoxide.nix b/platforms/home-manager/modules/nmasur/presets/programs/zoxide.nix index 69d26a2..b6cff0d 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/zoxide.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/zoxide.nix @@ -1,6 +1,5 @@ { config, - pkgs, lib, ... }: diff --git a/platforms/home-manager/modules/nmasur/profiles/extra.nix b/platforms/home-manager/modules/nmasur/profiles/extra.nix index d723910..980d19f 100644 --- a/platforms/home-manager/modules/nmasur/profiles/extra.nix +++ b/platforms/home-manager/modules/nmasur/profiles/extra.nix @@ -31,6 +31,8 @@ in pkgs.duf # Basic disk information (df) pkgs.pandoc # Convert text documents pkgs.mpd # TUI slideshows + pkgs.doggo # DNS client (dig) + pkgs.bottom # System monitor (top) ]; programs.fish.shellAliases = { diff --git a/platforms/nixos/modules/nmasur/profiles/base.nix b/platforms/nixos/modules/nmasur/profiles/base.nix index 9969bf0..2030c4c 100644 --- a/platforms/nixos/modules/nmasur/profiles/base.nix +++ b/platforms/nixos/modules/nmasur/profiles/base.nix @@ -1,5 +1,6 @@ { config, + pkgs, lib, ... }: @@ -31,6 +32,14 @@ in ]; }; + # Basic common system packages for all devices + environment.systemPackages = [ + pkgs.git + pkgs.vim + pkgs.wget + pkgs.curl + ]; + # Include home-manager config in NixOS home-manager = { sharedModules = [ ../../../../home-manager ]; diff --git a/platforms/nixos/modules/nmasur/profiles/on-premises.nix b/platforms/nixos/modules/nmasur/profiles/home.nix similarity index 92% rename from platforms/nixos/modules/nmasur/profiles/on-premises.nix rename to platforms/nixos/modules/nmasur/profiles/home.nix index 6fa2a72..998a98c 100644 --- a/platforms/nixos/modules/nmasur/profiles/on-premises.nix +++ b/platforms/nixos/modules/nmasur/profiles/home.nix @@ -6,12 +6,13 @@ }: let - cfg = config.nmasur.profiles.on-premises; + cfg = config.nmasur.profiles.home; in { - options.nmasur.profiles.on-premises.enable = lib.mkEnableOption "on-premises machine settings"; + options.nmasur.profiles.home.enable = + lib.mkEnableOption "home (on-premises, physical) machine settings"; config = lib.mkIf cfg.enable {