Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darwin support #1

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore(darwin): did darwin stuff
  • Loading branch information
bddvlpr committed May 15, 2024
commit 717cee2bbed0b6198ca4dbe30a0cd53f72136eeb
21 changes: 21 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";

nix-darwin.url = "github:lnl7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";

home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";

Expand Down
4 changes: 4 additions & 0 deletions modules/darwin/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
home-manager = import ./home-manager;
nix-daemon = import ./nix-daemon;
}
33 changes: 33 additions & 0 deletions modules/darwin/home-manager/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
inputs,
outputs,
lib,
config,
system,
...
}: let
inherit (inputs.home-manager.darwinModules) home-manager;
inherit (lib) mkIf mkOption types;

cfg = config.sysc.home-manager;
in {
imports = [home-manager];

options.sysc.home-manager = {
enable = mkOption {
type = types.bool;
default = true;
description = "Whether to enable home-manager.";
};
};

config = mkIf cfg.enable {
home-manager = {
users.bddvlpr = import ./users/bddvlpr.nix;
extraSpecialArgs = {
inherit inputs outputs system;
nixosConfig = config;
};
};
};
}
11 changes: 11 additions & 0 deletions modules/darwin/home-manager/users/bddvlpr.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{outputs, ...}: {
imports = with outputs.homeManagerModules; [
fish
git
gpg
helix
zsh
];

home.stateVersion = "24.05";
}
3 changes: 3 additions & 0 deletions modules/darwin/nix-daemon/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
services.nix-daemon.enable = true;
}
2 changes: 2 additions & 0 deletions modules/home/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
firefox = import ./firefox;
fish = import ./fish;
git = import ./git;
gpg = import ./gpg;
helix = import ./helix;
Expand All @@ -9,4 +10,5 @@
stylix = import ./stylix;
waybar = import ./waybar;
wofi = import ./wofi;
zsh = import ./zsh;
}
17 changes: 13 additions & 4 deletions modules/shared/fish/default.nix → modules/home/fish/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
lib,
pkgs,
...
}: {
}: let
inherit (lib.strings) hasSuffix;

isDarwin = hasSuffix "-darwin" pkgs.system;
in {
programs.fish = {
enable = true;

shellAbbrs = {
shellAbbrs = let
build-command =
if isDarwin
then "darwin-rebuild --flake ."
else "sudo nixos-rebuild --flake /etc/nixos";
in {
n = "nix";
nb = "nix build";
nbn = "nix build nixpkgs#";
Expand All @@ -18,8 +27,8 @@
ns = "nix shell";
nsn = "nix shell nixpkgs#";

snr = "sudo nixos-rebuild --flake /etc/nixos";
snrs = "sudo nixos-rebuild --flake /etc/nixos switch";
snr = "${build-command} --flake /etc/nixos";
snrs = "${build-command} switch";
};

shellAliases = let
Expand Down
39 changes: 39 additions & 0 deletions modules/home/zsh/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
lib,
pkgs,
...
}: let
inherit (lib.strings) hasSuffix;

isDarwin = hasSuffix "-darwin" pkgs.system;
in {
programs.zsh = {
enable = true;

shellAliases = let
inherit (lib) getExe;

build-command =
if isDarwin
then "darwin-rebuild --flake ."
else "sudo nixos-rebuild --flake /etc/nixos";
in {
n = "nix";
nb = "nix build";
nbn = "nix build nixpkgs#";
nf = "nix flake";
nfu = "nix flake update";
nfmt = "nix fmt";
nr = "nix run";
nrn = "nix run nixpkgs#";
ns = "nix shell";
nsn = "nix shell nixpkgs#";

snr = "${build-command} --flake /etc/nixos";
snrs = "${build-command} switch";

ls = "${getExe pkgs.eza} --icons -F -H --group-directories-first --git";
cat = "${getExe pkgs.bat} -pp --theme=base16";
};
};
}
1 change: 1 addition & 0 deletions modules/module.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
flake = {
darwinModules = import ./darwin;
homeManagerModules = import ./home;
nixosModules = import ./nixos;
sharedModules = import ./shared;
Expand Down
1 change: 1 addition & 0 deletions modules/nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
general = import ./general;
gpg-agent = import ./gpg-agent;
hardware = import ./hardware;
home-manager = import ./home-manager;
impermanence = import ./impermanence;
networking = import ./networking;
sudo = import ./sudo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

cfg = config.sysc.home-manager;
in {
# TODO: Interchangable with darwinModules.
imports = [home-manager];

options.sysc.home-manager = {
Expand Down
3 changes: 1 addition & 2 deletions modules/shared/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
fish = import ./fish;
home-manager = import ./home-manager;
nix = import ./nix;
shells = import ./shells;
users-bddvlpr = import ./users/bddvlpr.nix;
}
6 changes: 6 additions & 0 deletions modules/shared/shells/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
programs = {
fish.enable = true;
zsh.enable = true;
};
}
31 changes: 24 additions & 7 deletions modules/shared/users/bddvlpr.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
{pkgs, ...}: {
users.users.bddvlpr = {
isNormalUser = true;
shell = pkgs.fish;
extraGroups = ["wheel" "audio" "video" "networkmanager"];
hashedPassword = "$y$j9T$loVbb4dcOYqZmhAC3NScI1$NmvBmCrmuybhIhaM25x6.X2AgFKkvk9Upfr8GyqCA.3";
};
{
lib,
pkgs,
system,
...
}: let
inherit (lib) mkIf mkMerge;
inherit (lib.strings) hasSuffix;

isDarwin = hasSuffix "-darwin" pkgs.system;
in {
users.users.bddvlpr = mkMerge [
{
shell = pkgs.fish;
}
(mkIf (!isDarwin) {
isNormalUser = true;
extraGroups = ["wheel" "audio" "video" "networkmanager"];
hashedPassword = "$y$j9T$loVbb4dcOYqZmhAC3NScI1$NmvBmCrmuybhIhaM25x6.X2AgFKkvk9Upfr8GyqCA.3";
})
(mkIf isDarwin {
home = "/Users/bddvlpr";
})
];
}
2 changes: 2 additions & 0 deletions systems/apollo/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
31 changes: 26 additions & 5 deletions systems/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
config.allowUnfree = true;
};

mkSystem = host: system:
mkNixOS = host: system:
withSystem system ({pkgs, ...}: {
"${host}" = nixosSystem {
inherit system;
Expand All @@ -29,9 +29,30 @@
++ builtins.attrValues outputs.sharedModules;
};
});

mkDarwin = host: system:
withSystem system ({pkgs, ...}: {
"${host}" = inputs.nix-darwin.lib.darwinSystem {
inherit system;
pkgs = mkPkgs system;
specialArgs = {inherit inputs outputs host;};
modules =
[
./${host}
]
++ builtins.attrValues outputs.darwinModules
++ builtins.attrValues outputs.sharedModules;
};
});
in {
flake.nixosConfigurations = lib.mkMerge [
(mkSystem "dissension" "x86_64-linux")
(mkSystem "solaris" "x86_64-linux")
];
flake = {
nixosConfigurations = lib.mkMerge [
(mkNixOS "dissension" "x86_64-linux")
(mkNixOS "solaris" "x86_64-linux")
];

darwinConfigurations = lib.mkMerge [
(mkDarwin "apollo" "aarch64-darwin")
];
};
}