Skip to content

Commit

Permalink
refactor: alejandra -> nixfmt-rfc-style
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehamilton committed Jul 7, 2024
1 parent b69a233 commit b5a869b
Show file tree
Hide file tree
Showing 295 changed files with 4,675 additions and 4,021 deletions.
40 changes: 21 additions & 19 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,23 @@
};
};

outputs = inputs: let
lib = inputs.snowfall-lib.mkLib {
inherit inputs;
src = ./.;

snowfall = {
meta = {
name = "plusultra";
title = "Plus Ultra";
outputs =
inputs:
let
lib = inputs.snowfall-lib.mkLib {
inherit inputs;
src = ./.;

snowfall = {
meta = {
name = "plusultra";
title = "Plus Ultra";
};

namespace = "plusultra";
};

namespace = "plusultra";
};
};
in
in
lib.mkFlake {
channels-config = {
allowUnfree = true;
Expand Down Expand Up @@ -242,13 +244,13 @@
nixos-hardware.nixosModules.framework-11th-gen-intel
];

deploy = lib.mkDeploy {inherit (inputs) self;};
deploy = lib.mkDeploy { inherit (inputs) self; };

checks = builtins.mapAttrs (
system: deploy-lib: deploy-lib.deployChecks inputs.self.deploy
) inputs.deploy-rs.lib;

checks =
builtins.mapAttrs
(system: deploy-lib:
deploy-lib.deployChecks inputs.self.deploy)
inputs.deploy-rs.lib;
outputs-builder = channels: { formatter = channels.nixpkgs.nixfmt-rfc-style; };
}
// {
self = inputs.self;
Expand Down
9 changes: 4 additions & 5 deletions homes/aarch64-darwin/short@halite/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
lib,
pkgs,
config,
osConfig ? {},
osConfig ? { },
format ? "unknown",
namespace,
...
}:
with lib.${namespace}; {
with lib.${namespace};
{
plusultra = {
user = {
enable = true;
Expand All @@ -27,9 +28,7 @@ with lib.${namespace}; {
};
};

home.sessionPath = [
"$HOME/bin"
];
home.sessionPath = [ "$HOME/bin" ];

home.stateVersion = "22.11";
}
5 changes: 3 additions & 2 deletions homes/x86_64-linux/short/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
lib,
pkgs,
config,
osConfig ? {},

This comment has been minimized.

Copy link
@nicdumz

nicdumz Jan 15, 2025

Hey,

I like how your configs are structured, so have been learning with your repo amongst others. Thanks for sharing.

One thing puzzles me on this config and I hope it's OK to ask: my understanding is that snowfall-lib would have wanted a ${arch}/short@host/default.nix file and yet you omit the host here.

Could you share what this does and how it's working? As far as I could tell if I wanted to define config for one user across hosts I would have to set https://snowfall.org/guides/lib/systems/#snowfallorgusersnamehomeconfig e.g. in a nixosmodule.

Thanks!

This comment has been minimized.

Copy link
@nicdumz

nicdumz Jan 22, 2025

Filed snowfallorg/lib#159 ; thanks!

osConfig ? { },
format ? "unknown",
namespace,
...
}:
with lib.${namespace}; {
with lib.${namespace};
{
plusultra = {
cli-apps = {
zsh = enabled;
Expand Down
120 changes: 77 additions & 43 deletions lib/audio/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,96 @@ rec {
## Renames an alsa device from a given `name` using the new `description`.
##
#@ { name: String, description: String } -> { matches: List, apply_properties: Attrs }
mkAlsaRename = { name, description }: {
matches = [
[
[ "device.name" "matches" name ]
]
];
# actions = { "update-props" = { "node.description" = description; }; };
apply_properties = {
"device.description" = description;
mkAlsaRename =
{ name, description }:
{
matches = [
[
[
"device.name"
"matches"
name
]
]
];
# actions = { "update-props" = { "node.description" = description; }; };
apply_properties = {
"device.description" = description;
};
};
};

## Create a pipewire audio node.
##
#@ { name: String, factory: String ? "adapter", ... } -> { factory: String, args: Attrs }
mkAudioNode = args@{ name, factory ? "adapter", ... }: {
inherit factory;
args = (builtins.removeAttrs args [ "name" "description" ]) // {
"node.name" = name;
"node.description" = args.description or args."node.description";
"factory.name" = args."factory.name" or "support.null-audio-sink";
mkAudioNode =
args@{
name,
factory ? "adapter",
...
}:
{
inherit factory;
args =
(builtins.removeAttrs args [
"name"
"description"
])
// {
"node.name" = name;
"node.description" = args.description or args."node.description";
"factory.name" = args."factory.name" or "support.null-audio-sink";
};
};
};

## Create a virtual pipewire audio node.
##
#@ { name: String, ... } -> { factory: "adapter", args: Attrs }
mkVirtualAudioNode = args@{ name, ... }:
mkAudioNode (args // {
name = "virtual-${lib.toLower name}-audio";
description = "${name} (Virtual)";
"media.class" = args.class or args."media.class" or "Audio/Duplex";
"object.linger" = args."object.linger" or true;
"audio.position" = args."audio.position" or [ "FL" "FR" ];
"monitor.channel-volumes" = args."monitor.channel-volumes" or true;
});
mkVirtualAudioNode =
args@{ name, ... }:
mkAudioNode (
args
// {
name = "virtual-${lib.toLower name}-audio";
description = "${name} (Virtual)";
"media.class" = args.class or args."media.class" or "Audio/Duplex";
"object.linger" = args."object.linger" or true;
"audio.position" =
args."audio.position" or [
"FL"
"FR"
];
"monitor.channel-volumes" = args."monitor.channel-volumes" or true;
}
);

## Connect two pipewire audio nodes
##
#@ { name: String?, from: String, to: String, ... } -> { name: "libpipewire-module-loopback", args: Attrs }
mkBridgeAudioModule = args@{ from, to, ... }: {
name = "libpipewire-module-loopback";
args = (builtins.removeAttrs args [ "from" "to" "name" ]) // {
"node.name" =
if args ? name then
"${args.name}-bridge"
else
"${lib.toLower from}-to-${lib.toLower to}-bridge";
"audio.position" = args."audio.position" or [ "FL" "FR" ];
"capture.props" = {
"node.target" = from;
} // (args."capture.props" or { });
"playback.props" = {
"node.target" = to;
"monitor.channel-volumes" = true;
} // (args."playback.props" or { });
mkBridgeAudioModule =
args@{ from, to, ... }:
{
name = "libpipewire-module-loopback";
args =
(builtins.removeAttrs args [
"from"
"to"
"name"
])
// {
"node.name" =
if args ? name then "${args.name}-bridge" else "${lib.toLower from}-to-${lib.toLower to}-bridge";
"audio.position" =
args."audio.position" or [
"FL"
"FR"
];
"capture.props" = {
"node.target" = from;
} // (args."capture.props" or { });
"playback.props" = {
"node.target" = to;
"monitor.channel-volumes" = true;
} // (args."playback.props" or { });
};
};
};
}
6 changes: 3 additions & 3 deletions lib/colors/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
lib,
inputs,
snowfall-inputs,
}: rec {
}:
rec {
colors = {
without-hash = color:
builtins.substring 1 (builtins.stringLength color) color;
without-hash = color: builtins.substring 1 (builtins.stringLength color) color;

nord = {
nord0 = "#2E3440";
Expand Down
9 changes: 7 additions & 2 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ lib, inputs, snowfall-inputs }:
{
lib,
inputs,
snowfall-inputs,
}:

rec {
## Override a package's metadata
Expand All @@ -13,7 +17,8 @@ rec {
## ```
##
#@ Attrs -> Package -> Package
override-meta = meta: package:
override-meta =
meta: package:
package.overrideAttrs (attrs: {
meta = (attrs.meta or { }) // meta;
});
Expand Down
78 changes: 38 additions & 40 deletions lib/deploy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
lib,
inputs,
namespace,
}: let
}:
let
inherit (inputs) deploy-rs;
in rec {
in
rec {
## Create deployment configuration for use with deploy-rs.
##
## ```nix
Expand All @@ -17,46 +19,42 @@ in rec {
## ```
##
#@ { self: Flake, overrides: Attrs ? {} } -> Attrs
mkDeploy = {
self,
overrides ? {},
}: let
hosts = self.nixosConfigurations or {};
names = builtins.attrNames hosts;
nodes =
lib.foldl
(result: name: let
host = hosts.${name};
user = host.config.${namespace}.user.name or null;
inherit (host.pkgs) system;
in
mkDeploy =
{
self,
overrides ? { },
}:
let
hosts = self.nixosConfigurations or { };
names = builtins.attrNames hosts;
nodes = lib.foldl (
result: name:
let
host = hosts.${name};
user = host.config.${namespace}.user.name or null;
inherit (host.pkgs) system;
in
result
// {
${name} =
(overrides.${name} or {})
// {
hostname = overrides.${name}.hostname or "${name}";
profiles =
(overrides.${name}.profiles or {})
${name} = (overrides.${name} or { }) // {
hostname = overrides.${name}.hostname or "${name}";
profiles = (overrides.${name}.profiles or { }) // {
system =
(overrides.${name}.profiles.system or { })
// {
system =
(overrides.${name}.profiles.system or {})
// {
path = deploy-rs.lib.${system}.activate.nixos host;
}
// lib.optionalAttrs (user != null) {
user = "root";
sshUser = user;
}
// lib.optionalAttrs
(host.config.${namespace}.security.doas.enable or false)
{
sudo = "doas -u";
};
};
path = deploy-rs.lib.${system}.activate.nixos host;
}
// lib.optionalAttrs (user != null) {
user = "root";
sshUser = user;
}
// lib.optionalAttrs (host.config.${namespace}.security.doas.enable or false) { sudo = "doas -u"; };
};
})
{}
names;
in {inherit nodes;};
};
}
) { } names;
in
{
inherit nodes;
};
}
6 changes: 4 additions & 2 deletions lib/module/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{ lib, ... }:

with lib; rec {
with lib;
rec {
## Create a NixOS module option.
##
## ```nix
## lib.mkOpt nixpkgs.lib.types.str "My default" "Description of my option."
## ```
##
#@ Type -> Any -> String
mkOpt = type: default: description:
mkOpt =
type: default: description:
mkOption { inherit type default description; };

## Create a NixOS module option without a description.
Expand Down
Loading

0 comments on commit b5a869b

Please sign in to comment.