Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"formatter": {
"external": {
"command": "direnv",
"arguments": ["exec", ".", "treefmt", "--stdin", "{buffer_path}"]
}
}
}
8 changes: 6 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@
flake-compat.flake = false;
};

outputs = inputs@{ self, flake-parts, ... }:
outputs =
inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-darwin" ];
systems = [
"x86_64-linux"
"aarch64-darwin"
];

imports = [
./lib
Expand Down
6 changes: 4 additions & 2 deletions hosts/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{ self, ... }:
let inherit (self.lib.darwin) mkDarwinConfiguration;
in {
let
inherit (self.lib.darwin) mkDarwinConfiguration;
in
{
flake.darwinConfigurations = {
eMac = mkDarwinConfiguration {
system = "aarch64-darwin";
Expand Down
23 changes: 19 additions & 4 deletions hosts/eMac/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{ lib, suites, profiles, ... }: {
imports = with suites;
base ++ fonts ++ identity ++ [
{
lib,
suites,
profiles,
...
}:
{
imports =
with suites;
base
++ fonts
++ identity
++ [
profiles.users.ethan
profiles.builders.builder
profiles.builders.darwin-linux
Expand All @@ -24,7 +34,12 @@

taps = [ "homebrew/services" ];

casks = [ "steam" "utm" "vlc" "zoom" ];
casks = [
"steam"
"utm"
"vlc"
"zoom"
];

masApps = {
"Paprika Recipe Manager 3" = 1303222628;
Expand Down
23 changes: 18 additions & 5 deletions hosts/mercury/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{ suites, profiles, secrets, ... }: {
imports = with suites;
base ++ fonts ++ [ secrets.hosts.mercury.configuration ]
++ [ profiles.users.et ];
{
suites,
profiles,
secrets,
...
}:
{
imports =
with suites;
base ++ fonts ++ [ secrets.hosts.mercury.configuration ] ++ [ profiles.users.et ];

tilde.host.directory = "/Users/et/Workspace/tilde";

Expand All @@ -15,7 +21,14 @@
};

homebrew = {
casks = [ "bruno" "figma" "jabra-direct" "linear" "loom" "postico" ];
casks = [
"bruno"
"figma"
"jabra-direct"
"linear"
"loom"
"postico"
];

masApps = {
"Flow" = 1423210932;
Expand Down
15 changes: 9 additions & 6 deletions lib/compat/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(import (let lock = builtins.fromJSON (builtins.readFile ../../flake.lock);
in fetchTarball {
url =
"https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}) { src = ../../.; })
(import (
let
lock = builtins.fromJSON (builtins.readFile ../../flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ../../.; })
12 changes: 10 additions & 2 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ inputs, self, withSystem, ... }:
{
inputs,
self,
withSystem,
...
}:
let
haumea = inputs.haumea.lib;
lib = haumea.load {
Expand All @@ -8,4 +13,7 @@ let
flake = self;
};
};
in { flake.lib = lib; }
in
{
flake.lib = lib;
}
31 changes: 22 additions & 9 deletions lib/src/darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,34 @@ let

l = inputs.nixpkgs.lib // builtins;

sharedModules = (l.attrValues flake.darwinModules) ++ (with inputs; [
home-manager.darwinModules.home-manager
sops-nix.darwinModules.sops
]);
sharedModules =
(l.attrValues flake.darwinModules)
++ (with inputs; [
home-manager.darwinModules.home-manager
sops-nix.darwinModules.sops
]);

specialArgs = {
inherit flake inputs secrets homeConfigurations;
inherit
flake
inputs
secrets
homeConfigurations
;
suites = flake.suites.darwin;
profiles = flake.profiles.darwin;
};

mkDarwinConfiguration = { system, configuration }:
withSystem system ({ pkgs, ... }:
mkDarwinConfiguration =
{ system, configuration }:
withSystem system (
{ pkgs, ... }:
inputs.nix-darwin.lib.darwinSystem {
inherit pkgs system specialArgs;
modules = sharedModules ++ [ configuration ];
});
in { inherit mkDarwinConfiguration; }
}
);
in
{
inherit mkDarwinConfiguration;
}
18 changes: 12 additions & 6 deletions lib/src/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ let

l = inputs.nixpkgs.lib // builtins;

sharedModules = l.attrValues flake.homeModules
++ (with inputs; [ sops-nix.homeManagerModules.sops ]);
sharedModules =
l.attrValues flake.homeModules ++ (with inputs; [ sops-nix.homeManagerModules.sops ]);

extraSpecialArgs = {
inherit flake inputs secrets;
suites = flake.suites.home;
profiles = flake.profiles.home;
};

mkHomeManagerConfiguration = { system, configuration }:
withSystem system ({ pkgs, ... }:
mkHomeManagerConfiguration =
{ system, configuration }:
withSystem system (
{ pkgs, ... }:
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs extraSpecialArgs;
modules = sharedModules ++ [ configuration ];
});
}
);

in { inherit sharedModules extraSpecialArgs mkHomeManagerConfiguration; }
in
{
inherit sharedModules extraSpecialArgs mkHomeManagerConfiguration;
}
35 changes: 23 additions & 12 deletions lib/src/utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,31 @@ let
#
# Type:
# tree :: { [ name :: string ] :: ( leaf :: (T | ( branch :: ( leaf | tree )))), ... } -> { string -> leaf }
flattenTree = tree:
flattenTree =
tree:
let
inherit (builtins) concatStringsSep isPath isAttrs foldl' attrNames;
inherit (builtins)
concatStringsSep
isPath
isAttrs
foldl'
attrNames
;

# Takes an accumulator attribute set, a path in the form of a list of strings, and a value of what is at that
# path (either an attribute set, meaning a subdirectory; a path, meaning it's a file; or nothing, meaning it's an
# empty directory). Will turn the path into a dot-separated string (`foo/bar/biz` turns into `foo.bar.biz`) and
# will recurse over the subdirectory if it's an attribute set, add to our accumulator if it's a file, or just
# return the accumulator if it's neither
flatten = acc: path: leaf:
flatten =
acc: path: leaf:
# If the value is a path, then format the path as a dot-separated string and add this path and value to the
if isPath leaf then
(acc // { "${concatStringsSep "." path}" = leaf; })
# If the value is a set of attributes, this means there is a subtree -- run again for those attributes
# If the value is a set of attributes, this means there is a subtree -- run again for those attributes
else if isAttrs leaf then
(recurse acc path leaf)
# If it's not a value or a path (meaning null), just return the accumulated results without doing anything
# If it's not a value or a path (meaning null), just return the accumulated results without doing anything
else
acc;

Expand All @@ -34,12 +42,13 @@ let
# # `flatten` against that path and leaf
# let op = acc: leaf: (flatten (acc (path ++ [ leaf ]) tree.${leaf}));
# in foldl' (op acc (attrNames tree));
recurse = acc: path: leaf:
foldl' (acc: key: flatten acc (path ++ [ key ]) leaf.${key}) acc
(attrNames leaf);
recurse =
acc: path: leaf:
foldl' (acc: key: flatten acc (path ++ [ key ]) leaf.${key}) acc (attrNames leaf);

# Call `recurse`, starting with an empty accumulator, an empty path, and a tree to run the function against
in recurse { } [ ] tree;
in
recurse { } [ ] tree;

# Flattens attribute set of modules into a key-value set of dot-separated paths as keys and imported paths as values
#
Expand All @@ -50,6 +59,8 @@ let
# attrset :: {
# [ name :: string ] :: ( leaf :: (T | ( branch :: ( leaf | tree )))), ...
# } -> { string -> path }
importModules = attrset:
builtins.mapAttrs (_: value: (import value)) (flattenTree attrset);
in { inherit importModules; }
importModules = attrset: builtins.mapAttrs (_: value: (import value)) (flattenTree attrset);
in
{
inherit importModules;
}
13 changes: 8 additions & 5 deletions modules/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
let
inherit (self.lib) utils;
inherit (self.inputs) haumea;
in {
flake.darwinModules = utils.importModules (haumea.lib.load {
src = ./src;
loader = haumea.lib.loaders.path;
});
in
{
flake.darwinModules = utils.importModules (
haumea.lib.load {
src = ./src;
loader = haumea.lib.loaders.path;
}
);
}
Loading
Loading