Skip to content

Commit b2be62b

Browse files
committed
work macos config
1 parent 77f1729 commit b2be62b

28 files changed

+838
-0
lines changed

.config/nix/nix.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
experimental-features = nix-command flakes

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

cmd/get-users

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
6+
7+
USERS_FILE=$DIR/../config/users.nix
8+
9+
cat $USERS_FILE | sed 's|"||g; s|\[ ||g; s| \]||g'

cmd/set-users

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
6+
7+
USERS_FILE=$DIR/../config/users.nix
8+
9+
if [ $# -lt 1 ]; then
10+
echo "[]" > $USERS_FILE
11+
else
12+
echo "[ $(echo "$@" | sed 's| |" "|g; s|.*|"&"|') ]" > $USERS_FILE
13+
fi
14+
15+
git add --intent-to-add $USERS_FILE
16+
git update-index --assume-unchanged $USERS_FILE

config/users.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[ "justin" ]

flake.lock

Lines changed: 171 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
{
3+
inputs = {
4+
darwin = {
5+
url = "github:LnL7/nix-darwin";
6+
inputs.nixpkgs.follows = "nixpkgs";
7+
};
8+
9+
home-manager = {
10+
url = "github:nix-community/home-manager";
11+
inputs.nixpkgs.follows = "nixpkgs";
12+
};
13+
14+
mac-app-util.url = "github:hraban/mac-app-util";
15+
16+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
17+
};
18+
19+
outputs = inputs: let
20+
args = {
21+
inherit inputs;
22+
fn = {
23+
# mkUserAttrSet = (attrSet: builtins.listToAttrs (
24+
# map (user: { name = user; value = { test = "foo"; }; }) users
25+
# ));
26+
};
27+
};
28+
in {
29+
nixosConfigurations = {};
30+
31+
darwinConfigurations = {
32+
work = import ./hosts/work args;
33+
};
34+
};
35+
}

hosts/work/default.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
{ inputs, ... }:
3+
4+
inputs.darwin.lib.darwinSystem {
5+
system = "aarch64-darwin";
6+
specialArgs = { inherit inputs; };
7+
modules = [
8+
inputs.home-manager.darwinModules.home-manager
9+
inputs.mac-app-util.darwinModules.default
10+
../../modules/common
11+
../../modules/macos
12+
{
13+
bitwarden.enable = true;
14+
chrome.enable = true;
15+
kitty.enable = true;
16+
slack.enable = true;
17+
spotify.enable = true;
18+
vscode.enable = true;
19+
}
20+
];
21+
}

install

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
6+
7+
NIX=/nix/var/nix/profiles/default/bin/nix
8+
9+
function prompt_continue {
10+
read -p "Continue? (y/n): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
11+
}
12+
13+
if [ ! -e ~/.config/nix ]; then
14+
mkdir -p ~/.config
15+
16+
ln -s $DIR/.config/nix ~/.config/nix
17+
fi
18+
19+
if ! command -v $NIX 2>&1 >/dev/null; then
20+
curl -L https://nixos.org/nix/install | sh
21+
fi
22+
23+
read -p "Enter space-delimited users ($(./cmd/get-users)): " users
24+
25+
[ "$users" ] && ./cmd/set-users $users
26+
27+
$NIX run nix-darwin -- switch --flake .#$1
28+
29+
sudo reboot

modules/common/apps/bitwarden.nix

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{ config, lib, pkgs, ... }:
2+
3+
{
4+
options = {
5+
bitwarden = {
6+
enable = lib.mkEnableOption {
7+
default = false;
8+
};
9+
};
10+
};
11+
12+
config = lib.mkIf config.bitwarden.enable (lib.mkMerge [
13+
(lib.mkIf pkgs.stdenv.isLinux {
14+
environment.systemPackages = with pkgs; [ bitwarden-desktop ];
15+
})
16+
(lib.mkIf pkgs.stdenv.isDarwin {
17+
homebrew.casks = [ "bitwarden" ];
18+
})
19+
{
20+
chromium.extensions = [ "nngceckbapebfimnlniiiahkandclblb" ];
21+
}
22+
]);
23+
}

0 commit comments

Comments
 (0)