Refactor to support nix darwin

Checkpoint
This commit is contained in:
Nathan McCarty 2022-03-31 01:21:37 -04:00
parent d0ff8d2dd2
commit 11b51032a7
Signed by: thatonelutenist
GPG Key ID: D70DA3DD4D1E9F96
10 changed files with 232 additions and 118 deletions

View File

@ -0,0 +1,9 @@
# Linux Specific Core development libraries
{ config, pkgs, unstable, ... }:
{
environment.systemPackages = with pkgs; [
gcc
binutils
clang
];
}

View File

@ -10,11 +10,7 @@
# General development requirements
python3Full
cmake
gcc
unstable.libvterm-neovim
libtool
binutils
clang
gnumake
nixpkgs-fmt
# jq for interacting with JSON

View File

@ -6,9 +6,8 @@
rustup
# Install the latest rust analyzer
fenix.rust-analyzer
# Sccache and lld for faster builds
# Sccache for faster builds
sccache
lld_12
# Misc cargo utilites
cargo-binutils # Allow invoking the llvm tools included with the toolchain
cargo-edit # Command line Cargo.toml manipulation

25
darwin-modules/base.nix Normal file
View File

@ -0,0 +1,25 @@
{ config, pkgs, ... }:
{
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages =
[
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;
# Create /etc/bashrc 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;
}

24
darwin-modules/gpg.nix Normal file
View File

@ -0,0 +1,24 @@
# Configure gpg with yubikey support
{ config, pkgs, ... }:
{
# Setup environment for gpg agent
environment.shellInit = ''
export GPG_TTY="$(tty)"
gpg-connect-agent /bye
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
'';
programs = {
# Enable gpg-agent with ssh support
gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
};
# install gnupg and yubikey personalization
environment.systemPackages = with pkgs; [
gnupg
yubikey-personalization
];
}

View File

@ -1,12 +1,33 @@
{
"nodes": {
"darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1648278671,
"narHash": "sha256-1WrR9ex+rKTjZtODNUZQhkWYUprtfOkjOyo9YWL2NMs=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "4fdbb8168f61d31d3f90bb0d07f48de709c4fe79",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"emacs": {
"locked": {
"lastModified": 1648636019,
"narHash": "sha256-+ouEG2bFGttFe9xDgTJ6EQx6MbfZ8Mwvp+K1+CZJNGg=",
"lastModified": 1648697127,
"narHash": "sha256-Huz+aayKyCCUU1AVZrh5mC6O2BOLlIYFRFBuJ6w7CMc=",
"owner": "nix-community",
"repo": "emacs-overlay",
"rev": "af2208c42bca9e11703fd4d3853a56213e88cbb8",
"rev": "578eda92635e270c8b01edfd67aed6a3e8bf7d27",
"type": "github"
},
"original": {
@ -39,11 +60,11 @@
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1648366999,
"narHash": "sha256-Sdm0lI2ZBc70EnMMmvfDVY7gIM3M4c2L86EdQ9tKRE4=",
"lastModified": 1648677361,
"narHash": "sha256-WA7F77XrvIjNaAyW6/D06/xVdbr3TNchHHB+oJbyDio=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "888eac32bd657bfe0d024c8770130d80d1c02cd3",
"rev": "9580f6c42af2535dc7890edb681ead090f5105f2",
"type": "github"
},
"original": {
@ -148,6 +169,7 @@
},
"root": {
"inputs": {
"darwin": "darwin",
"emacs": "emacs",
"fenix": "fenix",
"home-manager": "home-manager",

View File

@ -16,18 +16,20 @@
};
sops-nix.url = "github:Mic92/sops-nix";
home-manager.url = "github:nix-community/home-manager";
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nixpkgs-unstable, fenix, emacs, mozilla, sops-nix, home-manager }:
outputs = { self, nixpkgs, nixpkgs-unstable, fenix, emacs, mozilla, sops-nix, home-manager, darwin }:
let
coreModules = [
./modules/common.nix
./modules/ssh.nix
baseModules = [
./applications/utils-core.nix
sops-nix.nixosModules.sops
home-manager.nixosModules.home-manager
## Setup binary caches
## Setup binary caches and other common nix config
({ pkgs, ... }: {
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# First install cachix, so we can discover new ones
environment.systemPackages = [ pkgs.cachix ];
# Then configure up the nix community cache
@ -38,8 +40,19 @@
binaryCachePublicKeys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
# Turn on flakes support (from within a flake, lamo)
package = pkgs.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
})
];
coreModules = baseModules ++ [
./modules/common.nix
./modules/ssh.nix
sops-nix.nixosModules.sops
home-manager.nixosModules.home-manager
## Setup sops
({ pkgs, config, ... }: {
# Add default secrets
@ -67,6 +80,7 @@
./modules/printing.nix
./applications/communications.nix
./applications/devel-core.nix
./applications/devel-core-linux.nix
./applications/devel-rust.nix
./applications/emacs.nix
./applications/image-editing.nix
@ -77,33 +91,57 @@
mozillaOverlay = import "${mozilla}";
in
{
nixosConfigurations.levitation = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
unstable = import nixpkgs-unstable {
config = { allowUnfree = true; };
overlays = [ emacs.overlay mozillaOverlay ];
system = "x86_64-linux";
nixosConfigurations = {
levitation = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
unstable = import nixpkgs-unstable {
config = { allowUnfree = true; };
overlays = [ emacs.overlay mozillaOverlay ];
system = "x86_64-linux";
};
fenix = fenix.packages.x86_64-linux;
};
fenix = fenix.packages.x86_64-linux;
modules = [
./hardware/levitation.nix
./modules/games.nix
./home-linux.nix
] ++ desktopModules;
};
modules = [
./hardware/levitation.nix
./modules/games.nix
] ++ desktopModules;
};
nixosConfigurations.x86vm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
unstable = import nixpkgs-unstable {
config = { allowUnfree = true; };
overlays = [ emacs.overlay ];
system = "x86_64-linux";
x86vm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
unstable = import nixpkgs-unstable {
config = { allowUnfree = true; };
overlays = [ emacs.overlay ];
system = "x86_64-linux";
};
fenix = fenix.packages.x86_64-linux;
};
fenix = fenix.packages.x86_64-linux;
modules = [ ./home-linux.nix ] ++ desktopModules;
};
};
darwinConfigurations = {
"Nathans-MacBook-Pro" = darwin.lib.darwinSystem {
system = "x86_64-darwin";
specialArgs = {
unstable = import nixpkgs-unstable {
config = { allowUnfree = true; };
overlays = [ emacs.overlay ];
system = "x86_64-darwin";
};
fenix = fenix.packages.x86_64-darwin;
};
modules = baseModules ++ [
./darwin-modules/base.nix
home-manager.darwinModules.home-manager
./home.nix
./darwin-modules/gpg.nix
./applications/devel-core.nix
./applications/devel-rust.nix
];
};
modules = desktopModules;
};
};
}

76
home-linux.nix Normal file
View File

@ -0,0 +1,76 @@
{ pkgs, config, unstable, ... }:
{
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
## Linux specific user configuration
users = {
mutableUsers = false;
isNormalUser = true;
users.nathan = {
extraGroups = [ "wheel" "networkmanager" "audio" "docker" "libvirtd" "uinput" "adbusers" "plugdev" ];
hashedPassword = "$6$ShBAPGwzKZuB7eEv$cbb3erUqtVGFo/Vux9UwT2NkbVG9VGCxJxPiZFYL0DIc3t4GpYxjkM0M7fFnh.6V8MoSKLM/TvOtzdWbYwI58.";
openssh.authorizedKeys.keys = [
# yubikey ssh key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRs6zVljIlQEZ8F+aEBqqbpeFJwCw3JdveZ8TQWfkev cardno:000615938515"
# Macbook pro key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBfkO7kq37RQMT8UE8zQt/vP4Ub7kizLw6niToJwAIe nathan@Nathans-MacBook-Pro.local"
];
};
};
# enable sudo
security.sudo.enable = true;
home-manager = {
users.nathan = {
# Alacritty configuration
programs.alacritty = {
enable = true;
settings = {
env = {
TERM = "xterm-256color";
ALACRITTY = "1";
};
font = {
normal.family = "FiraCode Nerd Font";
bold.family = "FiraCode Nerd Font";
italic.family = "FiraCode Nerd Font";
bold_italic.family = "FiraCode Nerd Font";
size = 9.0;
};
colors = {
primary = {
background = "0x103c48";
foreground = "0xadbcbc";
};
normal = {
black = "0x184956";
red = "0xfa5750";
green = "0x75b938";
yellow = "0xdbb32d";
blue = "0x4695f7";
magenta = "0xf275be";
cyan = "0x41c7b9";
white = "0x72898f";
};
bright = {
black = "0x2d5b69";
red = "0xff665c";
green = "0x84c747";
yellow = "0xebc13d";
blue = "0x58a3ff";
magenta = "0xff84cd";
cyan = "0x53d6c7";
white = "0xcad8d9";
};
};
};
};
## Multimedia
# Easyeffects for the eq
services.easyeffects.enable = true;
}
}
}

View File

@ -3,30 +3,12 @@
## Some general settings that were in the user configuration
# Set time zone
time.timeZone = "America/New_York";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
# enable sudo
security.sudo.enable = true;
## Setup user first
users = {
mutableUsers = false;
users.nathan = {
isNormalUser = true;
home = "/home/nathan";
description = "Nathan McCarty";
extraGroups = [ "wheel" "networkmanager" "audio" "docker" "libvirtd" "uinput" "adbusers" "plugdev" ];
hashedPassword = "$6$ShBAPGwzKZuB7eEv$cbb3erUqtVGFo/Vux9UwT2NkbVG9VGCxJxPiZFYL0DIc3t4GpYxjkM0M7fFnh.6V8MoSKLM/TvOtzdWbYwI58.";
shell = unstable.fish;
openssh.authorizedKeys.keys = [
# yubikey ssh key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRs6zVljIlQEZ8F+aEBqqbpeFJwCw3JdveZ8TQWfkev cardno:000615938515"
# Macbook pro key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBfkO7kq37RQMT8UE8zQt/vP4Ub7kizLw6niToJwAIe nathan@Nathans-MacBook-Pro.local"
];
shell = pkgs.fish;
};
};
## Home manager proper
@ -39,8 +21,6 @@
# Shell proper
programs.fish = {
enable = true;
# Use latest possible fish
package = unstable.fish;
# Setup our aliases
shellAliases = {
ls = "exa --icons";
@ -73,49 +53,6 @@
};
};
};
# Alacritty configuration
programs.alacritty = {
enable = true;
settings = {
env = {
TERM = "xterm-256color";
ALACRITTY = "1";
};
font = {
normal.family = "FiraCode Nerd Font";
bold.family = "FiraCode Nerd Font";
italic.family = "FiraCode Nerd Font";
bold_italic.family = "FiraCode Nerd Font";
size = 9.0;
};
colors = {
primary = {
background = "0x103c48";
foreground = "0xadbcbc";
};
normal = {
black = "0x184956";
red = "0xfa5750";
green = "0x75b938";
yellow = "0xdbb32d";
blue = "0x4695f7";
magenta = "0xf275be";
cyan = "0x41c7b9";
white = "0x72898f";
};
bright = {
black = "0x2d5b69";
red = "0xff665c";
green = "0x84c747";
yellow = "0xebc13d";
blue = "0x58a3ff";
magenta = "0xff84cd";
cyan = "0x53d6c7";
white = "0xcad8d9";
};
};
};
};
# Git configuration
programs.git = {
enable = true;
@ -197,16 +134,13 @@
};
};
};
## Multimedia
# Easyeffects for the eq
services.easyeffects.enable = true;
};
};
## Misc packages that were in user.nix
# Install general use packages
environment.systemPackages = with pkgs; [
# Install our shell of choice
unstable.fish
fish
# Install rclone
rclone
];

View File

@ -1,14 +1,5 @@
{ config, pkgs, ... }:
{
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Turn on flakes support (from within a flake, lamo)
nix = {
package = pkgs.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
# Turn on compressed memory swap
zramSwap = {
enable = true;