Fix home-manager impurity and add brew configuration

This commit is contained in:
Dave Gallant
2021-06-27 10:34:51 -04:00
parent 860ae35a49
commit 893964169e
18 changed files with 133 additions and 58 deletions

View File

@@ -18,7 +18,6 @@ sudo ./rebuild.sh switch
1. Install the latest unstable nix from https://github.com/numtide/nix-unstable-installer (to get nix flakes)
1. Install nix-darwin: https://github.com/LnL7/nix-darwin
1. Add home-manager channel: `nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager; nix-channel --update` (TODO: this requirement should be removed in the future)
```sh
./rebuild.sh switch

View File

@@ -92,7 +92,6 @@ in
# imaging
gifsicle
gimp
# video
youtube-dl
@@ -195,6 +194,7 @@ in
deluge
discord
firefox
gimp
minecraft
postman
signal-desktop

6
flake.lock generated
View File

@@ -27,11 +27,11 @@
]
},
"locked": {
"lastModified": 1624746582,
"narHash": "sha256-5RXicZDUxLjzz64oWXoRqAaTsfnG1oucIB3UIQa0rMI=",
"lastModified": 1624796413,
"narHash": "sha256-uQWxfcs4MGeWNUJxTRfuPvqaTVLTJAngc4IvxWNaCXs=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "8d3b273afef0e6c3d6d6e4239c9c9d79b1ab6ed7",
"rev": "f4998f0adccc60a2b463f1892e3eb42b9715a8ee",
"type": "github"
},
"original": {

View File

@@ -1,15 +1,20 @@
{
description = "nixos and macos configurations";
inputs = {
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "/nixpkgs";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
darwin.url = "github:lnl7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs";
darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, darwin, home-manager, nixpkgs, nixos-hardware }: {
@@ -42,7 +47,7 @@
trustedUsers = [ "root" "dave" ];
};
nixpkgs.overlays = [ (import ./overlays) ];
nixpkgs.overlays = [ (import ./modules/overlays) ];
home-manager = {
useGlobalPkgs = true;
@@ -65,13 +70,15 @@
darwinConfigurations = {
demeter = darwin.lib.darwinSystem {
modules = [
home-manager.darwinModules.home-manager
./common/darwin.nix
./common/packages.nix
./machines/demeter/configuration.nix
./modules/darwin/default.nix
({ config, ... }: {
config = {
nixpkgs.overlays = [ (import ./overlays) ];
nixpkgs.overlays = [ (import ./modules/overlays) ];
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;

View File

@@ -1,49 +1,12 @@
{ pkgs, ... }:
{
imports = [ <home-manager/nix-darwin> ];
nixpkgs.config.allowUnfree = true;
environment = { variables = { LANG = "en_US.UTF-8"; }; };
networking = { hostName = "demeter"; };
system.defaults = {
NSGlobalDomain = {
AppleMeasurementUnits = "Centimeters";
AppleMetricUnits = 1;
AppleShowScrollBars = "Automatic";
AppleTemperatureUnit = "Celsius";
AppleKeyboardUIMode = 3;
ApplePressAndHoldEnabled = false;
InitialKeyRepeat = 10;
KeyRepeat = 3;
_HIHideMenuBar = true;
};
dock = {
autohide = true;
mru-spaces = false;
tilesize = 512;
};
finder = {
AppleShowAllExtensions = true;
QuitMenuItem = true;
FXEnableExtensionChangeWarning = false;
};
trackpad = {
Clicking = true;
TrackpadThreeFingerDrag = true;
TrackpadRightClick = true;
};
# Login and lock screen
loginwindow = { GuestEnabled = false; };
};
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
nix.package = pkgs.nixFlakes;

43
modules/darwin/brew.nix Normal file
View File

@@ -0,0 +1,43 @@
{ config, lib, pkgs, ... }:
let
checkBrew = "command -v brew > /dev/null";
in
{
environment = {
extraInit = ''
${checkBrew} || >&2 echo "brew is not installed (install it via https://brew.sh)"
'';
};
homebrew = {
enable = true;
autoUpdate = true;
global = {
brewfile = true;
noLock = true;
};
brews = [
"aws-sam-cli"
"fabianishere/personal/pam_reattach"
"netdata"
];
casks = [
"1password"
"visual-studio-code"
];
taps = [
"aws/tap"
"homebrew/bundle"
"homebrew/cask"
"homebrew/cask-fonts"
"homebrew/cask-versions"
"homebrew/core"
"homebrew/services"
];
};
}

View File

@@ -0,0 +1,6 @@
{ pkgs, ... }: {
imports = [
./brew.nix
./preferences.nix
];
}

View File

@@ -0,0 +1,57 @@
{ config, pkgs, ... }: {
system.defaults = {
loginwindow = {
GuestEnabled = false;
SHOWFULLNAME = false;
};
finder = {
AppleShowAllExtensions = true;
FXEnableExtensionChangeWarning = true;
_FXShowPosixPathInTitle = true;
};
trackpad = {
ActuationStrength = 0;
Clicking = true;
FirstClickThreshold = 1;
SecondClickThreshold = 1;
TrackpadRightClick = false;
};
# firewall
alf = {
# 0 = disabled 1 = enabled 2 = blocks all connections except for essential services
globalstate = 1;
loggingenabled = 0;
stealthenabled = 1;
};
dock = {
autohide = true;
autohide-delay = "0.0";
autohide-time-modifier = "1.0";
tilesize = 50;
static-only = false;
showhidden = false;
show-recents = false;
show-process-indicators = true;
orientation = "bottom";
mru-spaces = false;
};
NSGlobalDomain = {
"com.apple.sound.beep.feedback" = 0;
"com.apple.sound.beep.volume" = "0.000";
ApplePressAndHoldEnabled = false;
# delay before repeating keystrokes
InitialKeyRepeat = 10;
# delay between repeated keystrokes upon holding a key
KeyRepeat = 1;
AppleShowAllExtensions = true;
AppleShowScrollBars = "Automatic";
};
};
}

View File

@@ -4,17 +4,17 @@ cd "$(dirname "$0")" || exit
uname="$(uname -s)"
case "${uname}" in
Linux*) machine=linux;;
Darwin*) machine=mac;;
*) machine="unknown"
Linux*) machine=linux ;;
Darwin*) machine=mac ;;
*) machine="unknown" ;;
esac
if [[ "$machine" == "linux" ]]; then
exec nixos-rebuild -I nixos-config="machines/$(hostname)/configuration.nix" "$@" --flake '.#'
elif [[ "$machine" == "mac" ]]; then
exec darwin-rebuild "$@" --flake . --impure # TODO: What is causing this impurity?
else
echo 'Unsupported OS.'
echo 'Exiting...'
exit 1
if [[ "$machine" == "linux" ]]; then
exec nixos-rebuild -I nixos-config="machines/$(hostname)/configuration.nix" "$@" --flake '.#'
elif [[ "$machine" == "mac" ]]; then
exec darwin-rebuild "$@" --flake .
else
echo 'Unsupported OS.'
echo 'Exiting...'
exit 1
fi