-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
518 additions
and
726 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ ... }: | ||
|
||
let | ||
sharedModules = [ | ||
../shared/darwin/gpg.nix | ||
../shared/darwin/homebrew.nix | ||
../shared/darwin/network.nix | ||
../shared/darwin/packages.nix | ||
../shared/darwin/system.nix | ||
]; | ||
in | ||
|
||
{ | ||
# nix-darwin configurations | ||
parts.darwinConfigurations = { | ||
# Apple M1 | ||
eR17x = { | ||
system = "aarch64-darwin"; | ||
stateVersion = 4; | ||
modules = sharedModules; | ||
}; | ||
}; | ||
|
||
# NixOS configurations | ||
# parts.nixosConfigurations = { | ||
# linuxBased = { | ||
# system = "x86_64-linux"; | ||
# stateVersion = "23.05"; | ||
|
||
# modules = []; | ||
# }; | ||
# wsl2 = { | ||
# system = "x86_64-linux"; | ||
# stateVersion = "22.05"; # only change this if you know what you are doing. | ||
# wsl = true; | ||
|
||
# modules = [ ]; | ||
# }; | ||
#}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ config, lib, inputs, withSystem, ... }: | ||
|
||
let | ||
inherit lib; | ||
inherit (lib) types; | ||
|
||
cfg = config.parts.darwinConfigurations; | ||
configurations = builtins.mapAttrs (_: value: value._darwin) cfg; | ||
|
||
darwinOpts = { config, name, ... }: { | ||
options = { | ||
system = lib.mkOption { | ||
type = types.enum [ "aarch64-darwin" "x86_64-darwin" ]; | ||
description = "System architecture for the configuration."; | ||
}; | ||
|
||
stateVersion = lib.mkOption { | ||
type = types.int; | ||
description = "nix-darwin state version, changing this value DOES NOT update your system."; | ||
}; | ||
|
||
modules = lib.mkOption { | ||
type = types.listOf types.unspecified; | ||
description = "List of nix-darwin modules to include in the configuration."; | ||
}; | ||
|
||
_darwin = lib.mkOption { | ||
type = types.unspecified; | ||
readOnly = true; | ||
description = "Composed nix-darwin configuration."; | ||
}; | ||
}; | ||
|
||
config._darwin = withSystem config.system (ctx: | ||
inputs.darwin.lib.darwinSystem { | ||
inherit inputs; | ||
inherit (ctx) system; | ||
|
||
modules = config.modules ++ [ | ||
# Composed home-manager configuration. | ||
inputs.home.darwinModules.home-manager | ||
|
||
({ pkgs, ... }: { | ||
inherit (ctx) nix; | ||
nixpkgs = removeAttrs ctx.nixpkgs [ "hostPlatform" ]; | ||
_module.args = ctx.extraModuleArgs; | ||
networking.hostName = name; | ||
networking.computerName = name; | ||
system.stateVersion = config.stateVersion; | ||
environment.systemPackages = ctx.basePackagesFor pkgs; | ||
}) | ||
]; | ||
} | ||
); | ||
}; | ||
in | ||
{ | ||
options.parts.darwinConfigurations = lib.mkOption { | ||
type = types.attrsOf (types.submodule darwinOpts); | ||
}; | ||
|
||
config.flake.darwinConfigurations = configurations; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ self, inputs, ... }: | ||
|
||
{ | ||
imports = [ | ||
./home.nix | ||
./darwin.nix | ||
]; | ||
|
||
perSystem = { lib, pkgs, system, inputs', ... }: { | ||
formatter = inputs.nixpkgs-fmt.defaultPackage.${system}; | ||
|
||
_module.args = rec { | ||
# the nix package manager configurations and settings. | ||
nix = import ./nix.nix { | ||
inherit lib inputs inputs'; | ||
inherit (pkgs) stdenv; | ||
}; | ||
|
||
# nixpkgs (channel) configuration (not the flake input) | ||
nixpkgs = { | ||
config = lib.mkForce { | ||
allowBroken = true; | ||
allowUnfree = true; | ||
tarball-ttl = 0; | ||
|
||
# Experimental options, disable if you don't know what you are doing! | ||
contentAddressedByDefault = false; | ||
}; | ||
|
||
hostPlatform = system; | ||
|
||
overlays = lib.mkForce [ | ||
self.overlays.default | ||
]; | ||
}; | ||
|
||
# Extra arguments passed to the module system for nix-darwin, NixOS, and home-manager | ||
extraModuleArgs = { | ||
inherit inputs' system; | ||
inputs = lib.mkForce inputs; | ||
|
||
/* | ||
One can access these nixpkgs branches like so: | ||
`branches.stable.mpd' | ||
`branches.master.linuxPackages_xanmod' | ||
*/ | ||
branches = | ||
let | ||
pkgsFrom = branch: system: import branch { | ||
inherit system; | ||
inherit (nixpkgs) config overlays; | ||
}; | ||
in | ||
{ | ||
master = pkgsFrom inputs.master system; | ||
unstable = pkgsFrom inputs.unstable system; | ||
stable = pkgsFrom inputs.stable system; | ||
}; | ||
}; | ||
|
||
# NixOS and nix-darwin base environment.systemPackages | ||
basePackagesFor = pkgs: builtins.attrValues { | ||
inherit (pkgs) | ||
vim | ||
curl | ||
fd | ||
man-pages-posix | ||
wget | ||
git; | ||
|
||
home-manager = inputs'.home.packages.home-manager.override { path = "${inputs.home}"; }; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ config, lib, inputs, withSystem, ... }: | ||
|
||
let | ||
inherit lib; | ||
inherit (lib) types; | ||
|
||
cfg = config.parts.homeConfigurations; | ||
configurations = builtins.mapAttrs (_: value: value._home) cfg; | ||
|
||
homeOpts = opts@{ config, lib, name, ... }: { | ||
options = { | ||
system = lib.mkOption { | ||
type = types.enum [ | ||
"aarch64-darwin" | ||
"aarch64-linux" | ||
"x86_64-darwin" | ||
"x86_64-linux" | ||
]; | ||
|
||
description = "System architecture for the configuration."; | ||
}; | ||
|
||
stateVersion = lib.mkOption { | ||
type = types.str; | ||
description = "home-manager state version, changing this value DOES NOT update your config."; | ||
}; | ||
|
||
modules = lib.mkOption { | ||
type = types.listOf types.unspecified; | ||
description = "List of home-manager modules to include in the configuration."; | ||
}; | ||
|
||
_home = lib.mkOption { | ||
type = types.unspecified; | ||
readOnly = true; | ||
description = "Composed home-manager configuration."; | ||
}; | ||
}; | ||
|
||
config._home = withSystem config.system (ctx: | ||
inputs.home.lib.homeManagerConfiguration { | ||
# Default nixpkgs for home.nix | ||
pkgs = inputs.nixpkgs.legacyPackages.${ctx.system}; | ||
|
||
modules = config.modules ++ [ | ||
inputs.nix-index-database.hmModules.nix-index | ||
|
||
({ config, lib, pkgs, ... }: { | ||
_module.args = ctx.extraModuleArgs; | ||
nixpkgs = removeAttrs ctx.nixpkgs [ "hostPlatform" ]; | ||
|
||
home = { | ||
username = builtins.elemAt (lib.strings.split "@" name) 0; | ||
inherit (opts.config) stateVersion; | ||
|
||
packages = builtins.attrValues { | ||
inherit (pkgs) | ||
hello; | ||
}; | ||
|
||
homeDirectory = lib.mkMerge [ | ||
(lib.mkIf pkgs.stdenv.isDarwin "/Users/${config.home.username}") | ||
(lib.mkIf pkgs.stdenv.isLinux "/home/${config.home.username}") | ||
]; | ||
}; | ||
}) | ||
]; | ||
} | ||
); | ||
}; | ||
in | ||
{ | ||
options.parts.homeConfigurations = lib.mkOption { | ||
type = types.attrsOf (types.submodule homeOpts); | ||
}; | ||
|
||
config.flake.homeConfigurations = configurations; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ lib, stdenv, inputs, inputs' }: | ||
|
||
{ | ||
configureBuildUsers = true; | ||
|
||
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; | ||
|
||
registry = { | ||
system.flake = inputs.self; | ||
default.flake = inputs.nixpkgs; | ||
home-manager.flake = inputs.home; | ||
}; | ||
|
||
settings = { | ||
max-jobs = "auto"; | ||
auto-optimise-store = true; | ||
accept-flake-config = true; | ||
|
||
experimental-features = [ | ||
"auto-allocate-uids" | ||
"ca-derivations" | ||
"flakes" | ||
"nix-command" | ||
]; | ||
|
||
trusted-users = [ "r17" "nixos" "root" ]; | ||
|
||
trusted-substituters = [ | ||
"https://cache.komunix.org" | ||
"https://nix-community.cachix.org" | ||
"https://r17.cachix.org/" | ||
"https://efishery.cachix.org" | ||
]; | ||
|
||
trusted-public-keys = [ | ||
"efishery.cachix.org-1:ix7pi358GsGkH7oBTmKGkVj42yBcjxRPi6IQ9AbRc0o=" | ||
"r17.cachix.org-1:vz0nG6BCbdgTPn7SEiOwe/3QwvjH1sb/VV9WLcBtkAY=" | ||
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" | ||
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" | ||
]; | ||
} // (lib.optionalAttrs (stdenv.isDarwin && stdenv.isAarch64) { | ||
extra-platforms = "x86_64-darwin aarch64-darwin"; | ||
}); | ||
|
||
|
||
# enable garbage-collection on weekly and delete-older-than 30 day | ||
gc = { | ||
automatic = true; | ||
options = "--delete-older-than 30d"; | ||
}; | ||
|
||
# this is configuration for /etc/nix/nix.conf | ||
# so it will generated /etc/nix/nix.conf | ||
extraOptions = '' | ||
keep-outputs = true | ||
keep-derivations = true | ||
auto-allocate-uids = false | ||
builders-use-substitutes = true | ||
http-connections = 0 | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
_: | ||
|
||
{ | ||
flake.overlays.default = final: prev: { }; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
_: | ||
|
||
{ | ||
parts.homeConfigurations = { | ||
"r17@eR17x" = { | ||
system = "aarch64-darwin"; | ||
stateVersion = "23.05"; | ||
}; | ||
}; | ||
} |