From 4a86e70de43441d4dfcd253ece01666111235a54 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Wed, 7 Sep 2022 20:01:51 -0500 Subject: [PATCH] Works on Darwin --- flake.lock | 32 +++++++++---------- flake.nix | 9 ++++-- home/gui/chat.nix | 9 +++--- home/gui/default.nix | 18 +++++++---- home/gui/firefox.nix | 15 ++++----- home/gui/terminal.nix | 4 +-- hosts/work/default.nix | 2 -- modules-all/automatic/default.nix | 8 +++++ {modules => modules-all}/automatic/nix.nix | 2 -- .../automatic/programs.nix | 0 modules-all/default.nix | 8 +++++ {modules => modules-all}/xprograms.nix | 0 modules-darwin/default.nix | 10 ++++++ modules-linux/automatic/default.nix | 8 +++++ .../automatic/syncthing.nix | 0 .../automatic/users.nix | 0 {modules => modules-linux}/backup.nix | 0 modules-linux/default.nix | 22 +++++++++++++ {modules => modules-linux}/gnome.nix | 0 {modules => modules-linux}/home.nix | 0 {modules => modules-linux}/linode.nix | 0 modules-linux/linux.nix | 11 +++++++ {modules => modules-linux}/proxy.nix | 0 {modules => modules-linux}/rpi4.nix | 0 {modules => modules-linux}/tailscale.nix | 0 modules/automatic.nix | 10 ------ modules/darwin.nix | 18 ----------- modules/default.nix | 17 ---------- modules/linux.nix | 19 ----------- overlays/hms.nix | 9 +++++- result | 2 +- {modules/ssh => ssh}/id_ed25519 | 0 {modules/ssh => ssh}/id_ed25519.pub | 0 33 files changed, 123 insertions(+), 110 deletions(-) create mode 100644 modules-all/automatic/default.nix rename {modules => modules-all}/automatic/nix.nix (93%) rename {modules => modules-all}/automatic/programs.nix (100%) create mode 100644 modules-all/default.nix rename {modules => modules-all}/xprograms.nix (100%) create mode 100644 modules-darwin/default.nix create mode 100644 modules-linux/automatic/default.nix rename {modules => modules-linux}/automatic/syncthing.nix (100%) rename {modules => modules-linux}/automatic/users.nix (100%) rename {modules => modules-linux}/backup.nix (100%) create mode 100644 modules-linux/default.nix rename {modules => modules-linux}/gnome.nix (100%) rename {modules => modules-linux}/home.nix (100%) rename {modules => modules-linux}/linode.nix (100%) create mode 100644 modules-linux/linux.nix rename {modules => modules-linux}/proxy.nix (100%) rename {modules => modules-linux}/rpi4.nix (100%) rename {modules => modules-linux}/tailscale.nix (100%) delete mode 100644 modules/automatic.nix delete mode 100644 modules/darwin.nix delete mode 100644 modules/default.nix delete mode 100644 modules/linux.nix rename {modules/ssh => ssh}/id_ed25519 (100%) rename {modules/ssh => ssh}/id_ed25519.pub (100%) diff --git a/flake.lock b/flake.lock index cd348f3..e07ee11 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1652712410, - "narHash": "sha256-hMJ2TqLt0DleEnQFGUHK9sV2aAzJPU8pZeiZoqRozbE=", + "lastModified": 1662241716, + "narHash": "sha256-urqPvSvvGUhkwzTDxUI8N1nsdMysbAfjmBNZaTYBZRU=", "owner": "ryantm", "repo": "agenix", - "rev": "7e5e58b98c3dcbf497543ff6f22591552ebfe65b", + "rev": "c96da5835b76d3d8e8d99a0fec6fe32f8539ee2e", "type": "github" }, "original": { @@ -21,15 +21,15 @@ "darwin": { "inputs": { "nixpkgs": [ - "nixpkgs" + "nixunstable" ] }, "locked": { - "lastModified": 1650976225, - "narHash": "sha256-PGM65SQHS63Dd5MmLJo3GJsZP9lJVZmpWxluQoG1Dt8=", + "lastModified": 1662478528, + "narHash": "sha256-Myjd0HPL5lXri3NXOcJ6gP7IKod2eMweQBKM4uxgEGw=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "bb3baef6e115ae47bc2ab4973bd3a486488485b0", + "rev": "3b69bf3cc26ae19de847bfe54d6ab22d7381a90a", "type": "github" }, "original": { @@ -78,11 +78,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1659342832, - "narHash": "sha256-ePnxG4hacRd6oZMk+YeCSYMNUnHCe+qPLI0/+VaTu48=", + "lastModified": 1662099760, + "narHash": "sha256-MdZLCTJPeHi/9fg6R9fiunyDwP3XHJqDd51zWWz9px0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e43cf1748462c81202a32b26294e9f8eefcc3462", + "rev": "67e45078141102f45eff1589a831aeaa3182b41e", "type": "github" }, "original": { @@ -94,11 +94,11 @@ }, "nixunstable": { "locked": { - "lastModified": 1659219666, - "narHash": "sha256-pzYr5fokQPHv7CmUXioOhhzDy/XyWOIXP4LZvv/T7Mk=", + "lastModified": 1662019588, + "narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7b9be38c7250b22d829ab6effdee90d5e40c6e5c", + "rev": "2da64a81275b68fdad38af669afeda43d401e94b", "type": "github" }, "original": { @@ -110,11 +110,11 @@ }, "nurpkgs": { "locked": { - "lastModified": 1659423577, - "narHash": "sha256-i2wSHqFqu4xpBJU/o9SRpQblAHknnEtyeN6Kuq/c1JA=", + "lastModified": 1662575201, + "narHash": "sha256-hLWrWQ7PRLiKYzYMgICzktqZSN+r7i7zol6UVebn7Rg=", "owner": "nix-community", "repo": "NUR", - "rev": "0bdb7691364dc93c8f04016c0ed395b675bdc50c", + "rev": "8bdab6eab89b870fc90fa0ec766b4e8c0d8c33ba", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index acfb078..b93aceb 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,7 @@ }; darwin = { url = "github:lnl7/nix-darwin/master"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "nixunstable"; }; nurpkgs.url = "github:nix-community/NUR"; }; @@ -26,7 +26,8 @@ mods = hostname: [ { nixpkgs.overlays = [ nurpkgs.overlay local_overlay ]; } agenix.nixosModule - ./modules + ./modules-all + ./modules-linux ./hosts/${hostname} home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; @@ -44,8 +45,10 @@ }; darwinMods = hostname: [ + { nixpkgs.overlays = [ nurpkgs.overlay local_overlay ]; } inputs.agenix.nixosModule - ./modules + ./modules-all + ./modules-darwin ./hosts/${hostname} ]; diff --git a/home/gui/chat.nix b/home/gui/chat.nix index ffc9f8b..a6ec78f 100644 --- a/home/gui/chat.nix +++ b/home/gui/chat.nix @@ -1,8 +1,9 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: { - home.packages = with pkgs; [ + home.packages = with pkgs; ( if ( lib.hasSuffix "-darwin" pkgs.system) then + [] else + [ element-desktop - nheko - ]; + ]); } diff --git a/home/gui/default.nix b/home/gui/default.nix index 8ce60ed..adf2f0e 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -8,11 +8,17 @@ ]; home.packages = with pkgs; [ - bitwarden - gnucash - handbrake - onlyoffice-bin synology-drive-client - vlc - ]; + ] ++ ( if pkgs.system == "x86_64-darwin" then + [ + libreoffice-bin + ] else + [ + bitwarden + gnucash + handbrake + onlyoffice-bin + vlc + ] + ); } diff --git a/home/gui/firefox.nix b/home/gui/firefox.nix index d1b97c7..e3974e0 100644 --- a/home/gui/firefox.nix +++ b/home/gui/firefox.nix @@ -1,9 +1,10 @@ { lib, pkgs, ... }: let - ffPkgs = wayland: if wayland - then [ pkgs.firefox-wayland ] - else [ pkgs.firefox ]; + # For now, we ignore this and don't install it + ffPkgs = if ( lib.hasSuffix "-darwin" pkgs.system ) + then pkgs.firefox-unwrapped + else pkgs.firefox-wayland.override { cfg.enableGnomeExtensions = true; }; vars = { MOZ_ENABLE_WAYLAND = "1"; @@ -12,12 +13,8 @@ let in with lib; { programs.firefox = { - enable = true; - package = pkgs.firefox-wayland.override { - cfg = { - enableGnomeExtensions = true; - }; - }; + enable = (if (lib.hasSuffix "-darwin" pkgs.system) then false else true); + package = ffPkgs; extensions = with pkgs.nur.repos.rycee.firefox-addons; [ bitwarden octotree diff --git a/home/gui/terminal.nix b/home/gui/terminal.nix index 7d90605..822b30e 100644 --- a/home/gui/terminal.nix +++ b/home/gui/terminal.nix @@ -1,7 +1,7 @@ -{ ... }: +{ lib, pkgs, ... }: { - programs.gnome-terminal = { + programs.gnome-terminal = lib.mkIf ( pkgs.system != "x86_64-darwin") { enable = true; showMenubar = true; themeVariant = "dark"; diff --git a/hosts/work/default.nix b/hosts/work/default.nix index 2234a8e..a67ca90 100644 --- a/hosts/work/default.nix +++ b/hosts/work/default.nix @@ -1,6 +1,4 @@ { pkgs, ... }: { - services.nix-daemon.enable = true; - greg.darwin = true; } diff --git a/modules-all/automatic/default.nix b/modules-all/automatic/default.nix new file mode 100644 index 0000000..8e990d3 --- /dev/null +++ b/modules-all/automatic/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./nix.nix + ./programs.nix + ]; +} diff --git a/modules/automatic/nix.nix b/modules-all/automatic/nix.nix similarity index 93% rename from modules/automatic/nix.nix rename to modules-all/automatic/nix.nix index db570b5..f555dc6 100644 --- a/modules/automatic/nix.nix +++ b/modules-all/automatic/nix.nix @@ -5,8 +5,6 @@ nix = { package = pkgs.nixFlakes; - autoOptimiseStore = true; - # Keep freespace available, at a minimum, and enable Flakes extraOptions = '' experimental-features = nix-command flakes diff --git a/modules/automatic/programs.nix b/modules-all/automatic/programs.nix similarity index 100% rename from modules/automatic/programs.nix rename to modules-all/automatic/programs.nix diff --git a/modules-all/default.nix b/modules-all/default.nix new file mode 100644 index 0000000..c7c9579 --- /dev/null +++ b/modules-all/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./automatic + ./xprograms.nix + ]; +} diff --git a/modules/xprograms.nix b/modules-all/xprograms.nix similarity index 100% rename from modules/xprograms.nix rename to modules-all/xprograms.nix diff --git a/modules-darwin/default.nix b/modules-darwin/default.nix new file mode 100644 index 0000000..81c4be2 --- /dev/null +++ b/modules-darwin/default.nix @@ -0,0 +1,10 @@ +{ ... }: + +{ + system.stateVersion = 4; + programs = { + zsh.enable = true; + bash.enable = true; + }; + services.nix-daemon.enable = true; +} diff --git a/modules-linux/automatic/default.nix b/modules-linux/automatic/default.nix new file mode 100644 index 0000000..f20fb29 --- /dev/null +++ b/modules-linux/automatic/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./syncthing.nix + ./users.nix + ]; +} diff --git a/modules/automatic/syncthing.nix b/modules-linux/automatic/syncthing.nix similarity index 100% rename from modules/automatic/syncthing.nix rename to modules-linux/automatic/syncthing.nix diff --git a/modules/automatic/users.nix b/modules-linux/automatic/users.nix similarity index 100% rename from modules/automatic/users.nix rename to modules-linux/automatic/users.nix diff --git a/modules/backup.nix b/modules-linux/backup.nix similarity index 100% rename from modules/backup.nix rename to modules-linux/backup.nix diff --git a/modules-linux/default.nix b/modules-linux/default.nix new file mode 100644 index 0000000..9b25e49 --- /dev/null +++ b/modules-linux/default.nix @@ -0,0 +1,22 @@ +{ ... }: + +{ + imports = [ + ./automatic + ./backup.nix + ./gnome.nix + ./home.nix + ./linode.nix + ./linux.nix + ./proxy.nix + ./rpi4.nix + ./tailscale.nix + ]; + + system.stateVersion = "22.05"; + + # I am a fan of network manager, myself + networking.networkmanager.enable = true; + + nix.settings.auto-optimise-store = true; +} diff --git a/modules/gnome.nix b/modules-linux/gnome.nix similarity index 100% rename from modules/gnome.nix rename to modules-linux/gnome.nix diff --git a/modules/home.nix b/modules-linux/home.nix similarity index 100% rename from modules/home.nix rename to modules-linux/home.nix diff --git a/modules/linode.nix b/modules-linux/linode.nix similarity index 100% rename from modules/linode.nix rename to modules-linux/linode.nix diff --git a/modules-linux/linux.nix b/modules-linux/linux.nix new file mode 100644 index 0000000..a5ad118 --- /dev/null +++ b/modules-linux/linux.nix @@ -0,0 +1,11 @@ +{ config, lib, ... }: + +let + cfg = config.greg.linux; + +in with lib; { + options.greg.linux = mkEnableOption "This system is Linux"; + + config = mkIf cfg { + }; +} diff --git a/modules/proxy.nix b/modules-linux/proxy.nix similarity index 100% rename from modules/proxy.nix rename to modules-linux/proxy.nix diff --git a/modules/rpi4.nix b/modules-linux/rpi4.nix similarity index 100% rename from modules/rpi4.nix rename to modules-linux/rpi4.nix diff --git a/modules/tailscale.nix b/modules-linux/tailscale.nix similarity index 100% rename from modules/tailscale.nix rename to modules-linux/tailscale.nix diff --git a/modules/automatic.nix b/modules/automatic.nix deleted file mode 100644 index 2ec9bf1..0000000 --- a/modules/automatic.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ ... }: - -{ - imports = [ - ./automatic/nix.nix - ./automatic/programs.nix - ./automatic/syncthing.nix - # Users imported only for Linux machines - ]; -} diff --git a/modules/darwin.nix b/modules/darwin.nix deleted file mode 100644 index e15893a..0000000 --- a/modules/darwin.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.greg.darwin; - -in with lib; { - options = { - greg.darwin = mkEnableOption "This system is Darwin"; - }; - - config = mkIf cfg { - system.stateVersion = 4; - programs = { - zsh.enable = true; - bash.enable = true; - }; - }; -} diff --git a/modules/default.nix b/modules/default.nix deleted file mode 100644 index 26ee429..0000000 --- a/modules/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ ... }: - -{ - imports = [ - ./automatic.nix - ./backup.nix - ./darwin.nix - ./home.nix - ./gnome.nix - ./linode.nix - ./linux.nix - ./proxy.nix - ./rpi4.nix - ./tailscale.nix - ./xprograms.nix - ]; -} diff --git a/modules/linux.nix b/modules/linux.nix deleted file mode 100644 index 850317f..0000000 --- a/modules/linux.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.greg.linux; - -in with lib; { - options.greg.linux = mkEnableOption "This system is Linux"; - - config = mkIf cfg { - imports = [ - ./automatic/users.nix - ]; - - system.stateVersion = "22.05"; - - # I am a fan of network manager, myself - networking.networkmanager.enable = true; - }; -} diff --git a/overlays/hms.nix b/overlays/hms.nix index b3cefb1..a89d443 100644 --- a/overlays/hms.nix +++ b/overlays/hms.nix @@ -9,11 +9,18 @@ else target="gui" fi +if [ "$(uname -s)" == "Darwin" ]; then + src="$HOME/.config/nix/" + target=gui +else + src=/etc/nixos +fi + # Build and switch echo "Building $(uname -m)-$target" dest=$(mktemp -d) pushd "$dest" > /dev/null -nix build --impure /etc/nixos#homeConfigurations.$(uname -m)-$target.activationPackage +nix build --impure "$src#homeConfigurations.$(uname -m)-$target.activationPackage" ./result/activate popd > /dev/null rm -r "$dest" diff --git a/result b/result index 8a12386..ed0f1f7 120000 --- a/result +++ b/result @@ -1 +1 @@ -/nix/store/crvk81fyaw1jhqlylxnjcd2y90xpgalr-darwin-system-21.11.20220418.7b38b03+darwin4.bb3baef \ No newline at end of file +/nix/store/xz2mcip95r90gdahyff2vn87hilw7lhp-darwin-system-22.05.20220801.e43cf17+darwin4.bb3baef \ No newline at end of file diff --git a/modules/ssh/id_ed25519 b/ssh/id_ed25519 similarity index 100% rename from modules/ssh/id_ed25519 rename to ssh/id_ed25519 diff --git a/modules/ssh/id_ed25519.pub b/ssh/id_ed25519.pub similarity index 100% rename from modules/ssh/id_ed25519.pub rename to ssh/id_ed25519.pub