Add support for darwin

darwin
Stef Dunlap 9 months ago
parent baef0e9044
commit fa9ee6bfed
  1. 1
      .gitignore
  2. 41
      conf/darwin.nix
  3. 43
      conf/darwin_link_apps.nix
  4. 9
      conf/workstation.nix
  5. 61
      flake.lock
  6. 116
      flake.nix
  7. 43
      home/darwin_link_apps.nix
  8. 16
      home/kindrobot-linux.nix
  9. 20
      home/kindrobot.nix

1
.gitignore vendored

@ -0,0 +1 @@
result

@ -0,0 +1,41 @@
{ config, pkgs, inputs, ... }:
{
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages =
[
pkgs.alacritty
pkgs.emacs
pkgs.neovim
pkgs.vim
];
# Use a custom configuration.nix location.
# $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
# environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; # Enables use of `nix-shell -p ...` etc
registry.nixpkgs.flake = inputs.nixpkgs; # Make `nix shell` etc use pinned nixpkgs
extraOptions = ''
extra-platforms = aarch64-darwin
experimental-features = nix-command flakes
'';
};
# For home-manager to work.
users.users.kindrobot.name = "kindrobot";
users.users.kindrobot.home = "/Users/kindrobot";
# Create /etc/zshrc that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell on catalina
programs.fish.enable = true;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4;
}

@ -0,0 +1,43 @@
{ config
, lib
, ...
}:
{
# Nix-darwin does not link installed applications to the user environment. This means apps will not show up
# in spotlight, and when launched through the dock they come with a terminal window. This is a workaround.
# Upstream issue: https://github.com/LnL7/nix-darwin/issues/214
system.activationScripts.applications.text = lib.mkForce ''
echo "setting up ~/Applications..." >&2
applications="$HOME/Applications"
nix_apps="$applications/Nix Apps"
# Needs to be writable by the user so that home-manager can symlink into it
# if ! test -d "$applications"; then
mkdir -p "$applications"
chown kindrobot: "$applications"
chmod u+w "$applications"
# fi
# Delete the directory to remove old links
rm -rf "$nix_apps"
mkdir -p "$nix_apps"
find ${config.system.build.applications}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
while read src; do
# Spotlight does not recognize symlinks, it will ignore directory we link to the applications folder.
# It does understand MacOS aliases though, a unique filesystem feature. Sadly they cannot be created
# from bash (as far as I know), so we use the oh-so-great Apple Script instead.
/usr/bin/osascript -e "
set fileToAlias to POSIX file \"$src\"
set applicationsFolder to POSIX file \"$nix_apps\"
tell application \"Finder\"
make alias file to fileToAlias at applicationsFolder
# This renames the alias; 'mpv.app alias' -> 'mpv.app'
set name of result to \"$(rev <<< "$src" | cut -d'/' -f1 | rev)\"
end tell
" 1>/dev/null
done
'';
}

@ -84,22 +84,13 @@
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
age
byobu
emacs
firefox
git
htop
kate
mosh
mu
neovim
qutebrowser
silver-searcher
sops
tmux
unzip
wget
];
# Some programs need SUID wrappers, can be configured further or are

@ -1,5 +1,26 @@
{
"nodes": {
"darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1663492236,
"narHash": "sha256-KzgrcFVhv/Ca7m83SaijE0W+tLHzjoypHZm9gHGS+cY=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "de4d41ee9fd12a60236c1f35cead7c511dac08eb",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -8,11 +29,11 @@
"utils": "utils"
},
"locked": {
"lastModified": 1661824092,
"narHash": "sha256-nSWLWytlXbeLrx5A+r5Pso7CvVrX5EgmIIXW/EXvPHQ=",
"lastModified": 1663328500,
"narHash": "sha256-7n+J/exp8ky4dmk02y5a9R7CGmJvHpzrHMzfEkMtSWA=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "5bd66dc6cd967033489c69d486402b75d338eeb6",
"rev": "5427f3d1f0ea4357cd4af0bffee7248d640c6ffc",
"type": "github"
},
"original": {
@ -23,48 +44,34 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1661720780,
"narHash": "sha256-AJNGyaB2eKZAYaPNjBZOzap87yL+F9ZLaFzzMkvega0=",
"owner": "NixOS",
"lastModified": 1663357389,
"narHash": "sha256-oYA2nVRSi6yhCBqS5Vz465Hw+3BQOVFEhfbfy//3vTs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a63021a330d8d33d862a8e29924b42d73037dd37",
"rev": "da6a05816e7fa5226c3f61e285ef8d9dfc868f3c",
"type": "github"
},
"original": {
"id": "nixpkgs",
"owner": "nixos",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1661720780,
"narHash": "sha256-AJNGyaB2eKZAYaPNjBZOzap87yL+F9ZLaFzzMkvega0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a63021a330d8d33d862a8e29924b42d73037dd37",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"root": {
"inputs": {
"darwin": "darwin",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable"
"nixpkgs": "nixpkgs"
}
},
"utils": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {

@ -2,62 +2,78 @@
description = "";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
darwin.url = "github:lnl7/nix-darwin/master";
darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, nixpkgs-unstable, home-manager }:
let
system = "x86_64-linux";
overlay-unstable = final: prev: {
unstable = import nixpkgs-unstable {
inherit system;
config.allowUnfree = true;
};
};
in {
nixosConfigurations.flippy = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
({ config, pkgs, ... }: {
nixpkgs.overlays = [ overlay-unstable ];
})
./conf/workstation.nix
./box/flippy.nix
./app/virtualbox.nix
./app/teamviewer.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.kindrobot.imports = [
./home/kindrobot.nix
./home/email_accounts.nix
];
}
];
};
nixosConfigurations.y500 = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
({ config, pkgs, ... }: {
nixpkgs.overlays = [ overlay-unstable ];
})
./conf/workstation.nix
./box/y500.nix
./app/virtualbox.nix
./app/teamviewer.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.kindrobot.imports = [
outputs = { self, nixpkgs, darwin, home-manager }:
{
nixosConfigurations.flippy = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ config, pkgs, ... }: {
nixpkgs.config.allowUnfreePredicate = (pkg: true);
})
./conf/workstation.nix
./box/flippy.nix
./app/virtualbox.nix
./app/teamviewer.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.kindrobot.imports = [
./home/kindrobot.nix
./home/kindrobot-linux.nix
./home/email_accounts.nix
];
}
];
};
nixosConfigurations.y500 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ config, pkgs, ... }: {
nixpkgs.config.allowUnfreePredicate = (pkg: true);
})
./conf/workstation.nix
./box/y500.nix
./app/virtualbox.nix
./app/teamviewer.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.kindrobot.imports = [
./home/kindrobot.nix
./home/kindrobot-linux.nix
./home/email_accounts.nix
];
}
];
};
darwinConfigurations.wapple = darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
({ config, pkgs, ... }: {
nixpkgs.config.allowUnfreePredicate = (pkg: true);
})
./conf/darwin.nix
./conf/darwin_link_apps.nix
home-manager.darwinModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.kindrobot = {
imports = [
./home/kindrobot.nix
./home/email_accounts.nix
./home/darwin_link_apps.nix
];
}
];
};
home.stateVersion = "22.11";
};
}
];
};
};
}

@ -0,0 +1,43 @@
{ config
, lib
, pkgs
, ...
}:
let
apps = pkgs.buildEnv {
name = "home-manager-applications";
paths = config.home.packages;
pathsToLink = "/Applications";
};
in
{
# Home-manager does not link installed applications to the user environment. This means apps will not show up
# in spotlight, and when launched through the dock they come with a terminal window. This is a workaround.
# Upstream issue: https://github.com/nix-community/home-manager/issues/1341
home.activation.addApplications = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
echo "setting up ~/Applications/Home Manager Apps..." >&2
nix_apps="$HOME/Applications/Home Manager Apps"
# Delete the directory to remove old links
$DRY_RUN_CMD rm -rf "$nix_apps"
$DRY_RUN_CMD mkdir -p "$nix_apps"
$DRY_RUN_CMD find ${apps}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
while read src; do
# Spotlight does not recognize symlinks, it will ignore directory we link to the applications folder.
# It does understand MacOS aliases though, a unique filesystem feature. Sadly they cannot be created
# from bash (as far as I know), so we use the oh-so-great Apple Script instead.
/usr/bin/osascript -e "
set fileToAlias to POSIX file \"$src\"
set applicationsFolder to POSIX file \"$nix_apps\"
tell application \"Finder\"
make alias file to fileToAlias at applicationsFolder
# This renames the alias; 'mpv.app alias' -> 'mpv.app'
set name of result to \"$(rev <<< "$src" | cut -d'/' -f1 | rev)\"
end tell
" 1>/dev/null
done
'';
}

@ -0,0 +1,16 @@
{ config, home-manager, pkgs, ... }:
{
home.packages = [
pkgs.barrier
pkgs.keepassxc
pkgs.mgba
pkgs.nextcloud-client
pkgs.obs-studio
pkgs.slack
pkgs.source-code-pro
pkgs.zoom-us
pkgs.zsh
];
services.emacs.enable = true;
}

@ -2,20 +2,15 @@
{
home.stateVersion = "22.11";
home.packages = [
pkgs.barrier
pkgs.keepassxc
pkgs.krita
pkgs.mgba
pkgs.age
pkgs.htop
pkgs.mosh
pkgs.mu
pkgs.nextcloud-client
pkgs.obs-studio
pkgs.neovim
pkgs.pass
pkgs.slack
pkgs.source-code-pro
pkgs.zoom-us
pkgs.zsh
pkgs.rpi-imager
pkgs.silver-searcher
pkgs.tmux
pkgs.wget
];
home.file.doom-d = {
source = ./doom.d;
@ -44,6 +39,5 @@
};
};
programs.z-lua.enable = true;
services.emacs.enable = true;
}

Loading…
Cancel
Save