Merge remote-tracking branch 'origin/darwin' into test

This commit is contained in:
Greg Hellings
2022-09-13 22:56:16 -05:00
41 changed files with 322 additions and 86 deletions
+8
View File
@@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./modules
./hosts/work
];
}
Generated
+25 -3
View File
@@ -18,6 +18,27 @@
"type": "github" "type": "github"
} }
}, },
"darwin": {
"inputs": {
"nixpkgs": [
"nixunstable"
]
},
"locked": {
"lastModified": 1662478528,
"narHash": "sha256-Myjd0HPL5lXri3NXOcJ6gP7IKod2eMweQBKM4uxgEGw=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "3b69bf3cc26ae19de847bfe54d6ab22d7381a90a",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -89,11 +110,11 @@
}, },
"nurpkgs": { "nurpkgs": {
"locked": { "locked": {
"lastModified": 1662437281, "lastModified": 1662716683,
"narHash": "sha256-2OiUGv6m1lnwHFSbw/ebzLilSGykTtDaquBvZWHr+2Q=", "narHash": "sha256-NU+YC3jT99fp8CPhtm+mgM/c8PP6DwIRzIGkuCO3Vss=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NUR", "repo": "NUR",
"rev": "e77801698156c004515b61f3000190dd40348ab8", "rev": "44284844e8329dfd07163965d0b9e2c3192911bc",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -105,6 +126,7 @@
"root": { "root": {
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"darwin": "darwin",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"nixunstable": "nixunstable", "nixunstable": "nixunstable",
+39 -5
View File
@@ -12,17 +12,29 @@
url = "github:nix-community/home-manager/release-22.05"; url = "github:nix-community/home-manager/release-22.05";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixunstable";
};
nurpkgs.url = "github:nix-community/NUR"; nurpkgs.url = "github:nix-community/NUR";
}; };
outputs = {nixpkgs, nixunstable, agenix, home-manager, nurpkgs, self}@inputs: outputs = {nixpkgs, nixunstable, agenix, home-manager, nurpkgs, self, ...}@inputs:
let let
local_overlay = import ./overlays; local_overlay = import ./overlays;
overlays = [
local_overlay
nurpkgs.overlay
];
overlaid = system: import nixpkgs {
inherit overlays system;
};
mods = hostname: [ mods = hostname: [
{ nixpkgs.overlays = [ nurpkgs.overlay local_overlay ]; } { nixpkgs.overlays = overlays; }
agenix.nixosModule agenix.nixosModule
./modules ./modules-all
./modules-linux
./hosts/${hostname} ./hosts/${hostname}
home-manager.nixosModules.home-manager { home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
@@ -39,6 +51,14 @@
modules = mods name; modules = mods name;
}; };
darwinMods = hostname: [
{ nixpkgs.overlays = overlays; }
inputs.agenix.nixosModule
./modules-all
./modules-darwin
./hosts/${hostname}
];
unstableMachine = system: name: inputs.nixunstable.lib.nixosSystem { unstableMachine = system: name: inputs.nixunstable.lib.nixosSystem {
system = system; system = system;
modules = mods name; modules = mods name;
@@ -64,7 +84,16 @@
"iso" = machine "x86_64-linux" "iso"; "iso" = machine "x86_64-linux" "iso";
}; };
darwinConfigurations = {
"C02G48H8MD6R" = inputs.darwin.lib.darwinSystem {
system = "x86_64-darwin";
specialArgs = inputs;
modules = darwinMods "work";
};
};
defaultPackage."x86_64-linux" = inputs.self.nixosConfigurations.iso.config.system.build.isoImage; defaultPackage."x86_64-linux" = inputs.self.nixosConfigurations.iso.config.system.build.isoImage;
defaultPackage."x86_64-darwin" = inputs.self.darwinConfigurations.C02G48H8MD6R.system;
homeConfigurations = ( homeConfigurations = (
import ./home { import ./home {
@@ -72,7 +101,12 @@
} }
); );
overlay = local_overlay; overlays = local_overlay;
modules = import ./modules; modules = import [
./modules-all
./modules-linux
./modules-darwin
];
packages = import ./overlays/packages.nix { pkgs = nixpkgs; };
}; };
} }
+25 -17
View File
@@ -1,25 +1,32 @@
{ nixpkgs, nurpkgs, home-manager, username ? builtins.getEnv "USER", ... }: { nixpkgs, nurpkgs, home-manager, username ? builtins.getEnv "USER", ... }:
let let
homeDirectory = if username == "root" then "/root" else "/home/${username}"; home = system:
configDir = "${homeDirectory}/.config"; if username == "root" then "/root" else
( if ( nixpkgs.lib.hasSuffix "-darwin" system ) then "/Users/${username}" else "/home/${username}" );
pkgs = import nixpkgs {
config.allowUnfree = true;
config.xdg.configHome = configDir;
overlays = [
nurpkgs.overlay
(import ../overlays)
];
};
nur = import nurpkgs {
inherit pkgs;
nur = pkgs;
};
mkhome = system: gui: mkhome = system: gui:
home-manager.lib.homeManagerConfiguration rec { let
homeDirectory = home system;
configDir = "${homeDirectory}/.config";
pkgs = import nixpkgs {
config.allowUnfree = true;
config.xdg.configHome = configDir;
overlays = [
nurpkgs.overlay
(import ../overlays)
];
};
nur = import nurpkgs {
inherit pkgs;
nur = pkgs;
};
in home-manager.lib.homeManagerConfiguration rec {
inherit pkgs system username homeDirectory; inherit pkgs system username homeDirectory;
stateVersion = "22.05"; stateVersion = "22.05";
configuration = import ./home.nix username { configuration = import ./home.nix username {
@@ -32,4 +39,5 @@ in {
"aarch64-nogui" = mkhome "aarch64-linux" false; "aarch64-nogui" = mkhome "aarch64-linux" false;
"x86_64-gui" = mkhome "x86_64-linux" true; "x86_64-gui" = mkhome "x86_64-linux" true;
"x86_64-nogui" = mkhome "x86_64-linux" false; "x86_64-nogui" = mkhome "x86_64-linux" false;
"x86_64-darwin" = mkhome "x86_64-darwin" true;
} }
+5 -4
View File
@@ -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 element-desktop
nheko ]);
];
} }
+12 -6
View File
@@ -8,11 +8,17 @@
]; ];
home.packages = with pkgs; [ home.packages = with pkgs; [
bitwarden
gnucash
handbrake
onlyoffice-bin
synology-drive-client synology-drive-client
vlc ] ++ ( if pkgs.system == "x86_64-darwin" then
]; [
libreoffice-bin
] else
[
bitwarden
gnucash
handbrake
onlyoffice-bin
vlc
]
);
} }
+6 -9
View File
@@ -1,9 +1,10 @@
{ lib, pkgs, ... }: { lib, pkgs, ... }:
let let
ffPkgs = wayland: if wayland # For now, we ignore this and don't install it
then [ pkgs.firefox-wayland ] ffPkgs = if ( lib.hasSuffix "-darwin" pkgs.system )
else [ pkgs.firefox ]; then pkgs.firefox-unwrapped
else pkgs.firefox-wayland.override { cfg.enableGnomeExtensions = true; };
vars = { vars = {
MOZ_ENABLE_WAYLAND = "1"; MOZ_ENABLE_WAYLAND = "1";
@@ -12,12 +13,8 @@ let
in with lib; in with lib;
{ {
programs.firefox = { programs.firefox = {
enable = true; enable = (if (lib.hasSuffix "-darwin" pkgs.system) then false else true);
package = pkgs.firefox-wayland.override { package = ffPkgs;
cfg = {
enableGnomeExtensions = true;
};
};
extensions = with pkgs.nur.repos.rycee.firefox-addons; [ extensions = with pkgs.nur.repos.rycee.firefox-addons; [
bitwarden bitwarden
octotree octotree
+2 -2
View File
@@ -1,7 +1,7 @@
{ ... }: { lib, pkgs, ... }:
{ {
programs.gnome-terminal = { programs.gnome-terminal = lib.mkIf ( pkgs.system != "x86_64-darwin") {
enable = true; enable = true;
showMenubar = true; showMenubar = true;
themeVariant = "dark"; themeVariant = "dark";
+2
View File
@@ -5,6 +5,8 @@
enable = true; enable = true;
serverAliveInterval = 60; serverAliveInterval = 60;
includes = ["config.local"];
matchBlocks = matchBlocks =
let let
nas = { user = "admin"; }; nas = { user = "admin"; };
+12 -1
View File
@@ -44,10 +44,12 @@
tspub = "sudo tailscale up --exit-node=linode"; tspub = "sudo tailscale up --exit-node=linode";
tshome = "sudo tailscale up --exit-node=2maccabees"; tshome = "sudo tailscale up --exit-node=2maccabees";
tsclear = "sudo tailscale up --exit-node=''"; tsclear = "sudo tailscale up --exit-node=''";
rebuild = "sudo nixos-rebuild switch";
}; };
configHeader = '' configHeader = ''
if '__NIX_DARWIN_SET_ENVIRONMENT_DONE' not in ''${...} or not $__NIX_DARWIN_SET_ENVIRONMENT_DONE:
source-bash /etc/bashrc
# set -e == $RAISE_SUBPROC_ERROR = True # set -e == $RAISE_SUBPROC_ERROR = True
# set -x == trace on; $XONSH_TRACE_SUBPROC = True # set -x == trace on; $XONSH_TRACE_SUBPROC = True
# $? == _.rtn # $? == _.rtn
@@ -61,6 +63,14 @@ xontrib load direnv
#$GOPATH = $HOME + '/.go' #$GOPATH = $HOME + '/.go'
#$JAVA_HOME = '/etc/alternatives/java_sdk' #$JAVA_HOME = '/etc/alternatives/java_sdk'
configFooter = '' configFooter = ''
def _rebuild(args):
import os
system = os.uname()
if system.sysname == 'Darwin':
darwin-rebuild --flake ~/.config/nix switch
else:
sudo nixos-rebuild switch
def _yaml2json(args, stdin=None, stdout=None): def _yaml2json(args, stdin=None, stdout=None):
import sys, yaml, json import sys, yaml, json
from yaml import CLoader from yaml import CLoader
@@ -95,6 +105,7 @@ def _newdock(args):
def _unknown_host(args): def _unknown_host(args):
sed -i -e @(args[0])d ~/.ssh/known_hosts sed -i -e @(args[0])d ~/.ssh/known_hosts
aliases['rebuild'] = _rebuild
aliases['yaml2json'] = _yaml2json aliases['yaml2json'] = _yaml2json
aliases['py2env'] = _py2env aliases['py2env'] = _py2env
aliases['py3env'] = _py3env aliases['py3env'] = _py3env
+15
View File
@@ -0,0 +1,15 @@
{ pkgs, ... }:
{
#greg.pypackages = with pkgs; [
# datadog-api-client
# datadog
# dateutil
# ipython
# pyyaml
# responses
# ruamel-yaml
# typing-extensions
# virtualenv
#];
}
Symlink
+1
View File
@@ -0,0 +1 @@
modules-all
+8
View File
@@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./nix.nix
./programs.nix
];
}
@@ -15,10 +15,6 @@ max-free = ${toString (5 * 1024 * 1024 * 1024) }
keep-outputs = true keep-outputs = true
keep-derivations = true keep-derivations = true
''; '';
# Use hardlinking instead of copying when possible
autoOptimiseStore = true;
}; };
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
system.stateVersion = "22.05";
} }
@@ -2,7 +2,16 @@
let let
myPackages = pypackages: with pypackages; [ myPackages = pypackages: with pypackages; [
pkgs.datadog-api-client
pkgs.xonsh-direnv pkgs.xonsh-direnv
datadog
dateutil
ipython
pyyaml
responses
ruamel-yaml
typing-extensions
virtualenv
]; ];
myPython = pkgs.python3.withPackages myPackages; myPython = pkgs.python3.withPackages myPackages;
@@ -10,6 +19,8 @@ in {
# Base packages that need to be in all my hosts # Base packages that need to be in all my hosts
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
agenix.defaultPackage."${system}" agenix.defaultPackage."${system}"
android-file-transfer
bitwarden-cli
diffutils diffutils
git git
gnupatch gnupatch
+8
View File
@@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./automatic
./xprograms.nix
];
}
+1
View File
@@ -0,0 +1 @@
modules
+10
View File
@@ -0,0 +1,10 @@
{ ... }:
{
system.stateVersion = 4;
programs = {
zsh.enable = true;
bash.enable = true;
};
services.nix-daemon.enable = true;
}
+8
View File
@@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./syncthing.nix
./users.nix
];
}
@@ -1,4 +1,6 @@
{ config, pkgs, agenix, ... }: # Only imported from the Linux modules
{ pkgs, ... }:
{ {
# Enable the OpenSSH daemon for remote control # Enable the OpenSSH daemon for remote control
+22
View File
@@ -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;
}
+11
View File
@@ -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 {
};
}
-12
View File
@@ -1,12 +0,0 @@
{ ... }:
{
imports = [
./automatic/nix.nix
./automatic/programs.nix
./automatic/syncthing.nix
./automatic/users.nix
];
# I am a fan of network manager, myself
networking.networkmanager.enable = true;
}
-15
View File
@@ -1,15 +0,0 @@
{ ... }:
{
imports = [
./automatic.nix
./backup.nix
./home.nix
./gnome.nix
./linode.nix
./proxy.nix
./rpi4.nix
./tailscale.nix
./xprograms.nix
];
}
+1
View File
@@ -0,0 +1 @@
experimental-features = nix-command flakes
+38
View File
@@ -0,0 +1,38 @@
{ lib, buildPythonPackage, fetchPypi, pkgs}:
let
pydeps = pypkgs: with pypkgs; [
certifi
dateutils
python-dateutil
typing-extensions
urllib3
];
in buildPythonPackage rec {
pname = "datadog-api-client";
version = "2.3.0";
src = fetchPypi {
inherit pname version;
sha256 = "CIEQlw8S2lZk1n+ld/Ne7lBx4SKaJZUZfNbw9KvUcjk=";
};
meta = with lib; {
description = "Datadog API client support";
homepage = "https://github.com/DataDog/datadog-api-client-python";
license = licenses.asl20;
maintainers = [];
};
doCheck = false;
buildInputs = with pkgs; [
(python3.withPackages pydeps)
];
nativeBuildInputs = with pkgs; [
(python3.withPackages pydeps)
git
];
}
+8 -3
View File
@@ -1,15 +1,20 @@
self: super: self: super:
{ {
xonsh-direnv = super.callPackage ./xonsh-direnv.nix { datadog-api-client = super.callPackage ./datadog-api-client.nix {
buildPythonPackage = self.python3.pkgs.buildPythonPackage; buildPythonPackage = self.python3.pkgs.buildPythonPackage;
fetchPypi = self.python.pkgs.fetchPypi; fetchPypi = self.python.pkgs.fetchPypi;
}; };
hms = super.callPackage ./hms.nix {
pkgs = self.pkgs;
};
xonsh = super.xonsh.overridePythonAttrs (old: rec{ xonsh = super.xonsh.overridePythonAttrs (old: rec{
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.xonsh-direnv ]; propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.xonsh-direnv ];
}); });
hms = super.callPackage ./hms.nix { xonsh-direnv = super.callPackage ./xonsh-direnv.nix {
pkgs = self.pkgs; buildPythonPackage = self.python3.pkgs.buildPythonPackage;
fetchPypi = self.python.pkgs.fetchPypi;
}; };
} }
+14 -4
View File
@@ -3,17 +3,27 @@
pkgs.writeShellScriptBin "hms" '' pkgs.writeShellScriptBin "hms" ''
set -eo pipefail set -eo pipefail
# Build different targets with GUI or not # Build different targets with GUI or not
if [ -z "$DISPLAY" ]; then
target="nogui" arch="$(uname -m)"
if [ "$(uname -s)" == "Darwin" ]; then
# On macOS
src="$HOME/.config/nix/"
target="''${arch}-darwin"
else else
target="gui" # On Linux/WSL2 systems
if [ -z "$DISPLAY" ]; then
target="''${arch}-nogui"
else
target="''${arch}-gui"
fi
src=/etc/nixos
fi fi
# Build and switch # Build and switch
echo "Building $(uname -m)-$target" echo "Building $(uname -m)-$target"
dest=$(mktemp -d) dest=$(mktemp -d)
pushd "$dest" > /dev/null pushd "$dest" > /dev/null
nix build --impure /etc/nixos#homeConfigurations.$(uname -m)-$target.activationPackage nix build --impure "$src#homeConfigurations.$target.activationPackage"
./result/activate ./result/activate
popd > /dev/null popd > /dev/null
rm -r "$dest" rm -r "$dest"
+23
View File
@@ -0,0 +1,23 @@
{ pkgs, ... }:
let
callPackage = pkgs.lib.callPackageWith pkgs;
lib = pkgs.lib;
python = pkgs.packages.python3;
in {
datadog-api-client = callPackage ./datadog-api-client.nix {
inherit pkgs lib;
buildPythonPackage = python.pkgs.buildPythonPackage;
fetchPypi = pkgs.python.pkgs.fetchPypi;
};
hms = pkgs.callPackage ./hms.nix {
inherit pkgs;
};
xonsh-direnv = pkgs.callPackage ./xonsh-direnv.nix {
buildPythonPackage = pkgs.python3.pkgs.buildPythonPackage;
fetchPypi = pkgs.python.pkgs.fetchPypi;
};
}
+4
View File
@@ -17,4 +17,8 @@ buildPythonPackage rec {
}; };
doCheck = false; doCheck = false;
nativeBuildInputs = [
pkgs.git
];
} }