Skip to content

Commit

Permalink
format with nixfmt-rfc-style
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbatm committed Mar 24, 2024
1 parent 230e03c commit 6b991b0
Show file tree
Hide file tree
Showing 23 changed files with 302 additions and 240 deletions.
20 changes: 11 additions & 9 deletions devshell.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
perSystem = { config, pkgs, ... }: {
devshells.default.packages = [
config.treefmt.build.wrapper
pkgs.nixos-anywhere
pkgs.sbctl
pkgs.sops
pkgs.ssh-to-age
];
};
perSystem =
{ config, pkgs, ... }:
{
devshells.default.packages = [
config.treefmt.build.wrapper
pkgs.nixos-anywhere
pkgs.sbctl
pkgs.sops
pkgs.ssh-to-age
];
};
}
18 changes: 9 additions & 9 deletions docs/default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{ inputs, self, ... }:
{
perSystem = { system, ... }: {
packages.docs = inputs.mkdocs-numtide.lib.${system}.mkDocs {
name = "zimbatm-docs";
src = self;
};
perSystem =
{ system, ... }:
{
packages.docs = inputs.mkdocs-numtide.lib.${system}.mkDocs {
name = "zimbatm-docs";
src = self;
};

devshells.default.packages = [
inputs.mkdocs-numtide.packages.${system}.default
];
};
devshells.default.packages = [ inputs.mkdocs-numtide.packages.${system}.default ];
};
}
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
treefmt-nix.url = "github:numtide/treefmt-nix";
};

outputs = inputs @ { flake-parts, systems, ... }:
outputs =
inputs@{ flake-parts, systems, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;
imports = [
Expand Down
89 changes: 55 additions & 34 deletions homeConfigurations/default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{ self, inputs, ... }:
let
hmConfig = pkgs: module:
hmConfig =
pkgs: module:
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;

extraSpecialArgs = { inherit inputs; };
extraSpecialArgs = {
inherit inputs;
};

modules = [
module
Expand All @@ -23,39 +26,57 @@ in
flake.homeModules.terminal = ./terminal;

# This is the flake that contains the home-manager configuration
perSystem = { pkgs, lib, system, ... }: {
# Run `nix run hm switch`
#
# TODO: set the home.homeDirectory and home.username dynamically
packages.home = pkgs.writeShellScriptBin "home" ''
set -euo pipefail
perSystem =
{
pkgs,
lib,
system,
...
}:
{
# Run `nix run hm switch`
#
# TODO: set the home.homeDirectory and home.username dynamically
packages.home = pkgs.writeShellScriptBin "home" ''
set -euo pipefail
export PATH=${pkgs.lib.makeBinPath [pkgs.git pkgs.coreutils pkgs.nix pkgs.jq pkgs.unixtools.hostname]}
declare -A profiles=(["x1"]="nixos" ["no1"]="nixos")
profile="terminal"
if [[ -n ''${profiles[$(hostname)]:-} ]]; then
profile=''${profiles[$(hostname)]}
fi
if [[ $profile == nixos ]]; then
echo "aborting: deployed by NixOS" >&2
exit 1
fi
if [[ "''${1:-}" == profile ]]; then
echo $profile
exit 0
fi
set -x
${inputs.home-manager.packages.${pkgs.system}.home-manager}/bin/home-manager --flake "${self}#$profile" "$@"
'';
export PATH=${
pkgs.lib.makeBinPath [
pkgs.git
pkgs.coreutils
pkgs.nix
pkgs.jq
pkgs.unixtools.hostname
]
}
declare -A profiles=(["x1"]="nixos" ["no1"]="nixos")
profile="terminal"
if [[ -n ''${profiles[$(hostname)]:-} ]]; then
profile=''${profiles[$(hostname)]}
fi
if [[ $profile == nixos ]]; then
echo "aborting: deployed by NixOS" >&2
exit 1
fi
if [[ "''${1:-}" == profile ]]; then
echo $profile
exit 0
fi
set -x
${
inputs.home-manager.packages.${pkgs.system}.home-manager
}/bin/home-manager --flake "${self}#$profile" "$@"
'';

# Stuff those in legacyPackages to make home-manager happy
legacyPackages.homeConfigurations.desktop = hmConfig pkgs ./desktop;
legacyPackages.homeConfigurations.sway = hmConfig pkgs ./sway;
legacyPackages.homeConfigurations.terminal = hmConfig pkgs ./terminal;
# Stuff those in legacyPackages to make home-manager happy
legacyPackages.homeConfigurations.desktop = hmConfig pkgs ./desktop;
legacyPackages.homeConfigurations.sway = hmConfig pkgs ./sway;
legacyPackages.homeConfigurations.terminal = hmConfig pkgs ./terminal;

# Add all the home configurations to the checks
checks = lib.mapAttrs'
(name: value: { name = "home-${name}"; value = value.activation-script; })
self.legacyPackages.${system}.homeConfigurations;
};
# Add all the home configurations to the checks
checks = lib.mapAttrs' (name: value: {
name = "home-${name}";
value = value.activation-script;
}) self.legacyPackages.${system}.homeConfigurations;
};
}
4 changes: 1 addition & 3 deletions homeConfigurations/desktop/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{ pkgs, ... }:
{
imports = [
../terminal
];
imports = [ ../terminal ];

programs.firefox.enable = true;
programs.vscode.enable = true;
Expand Down
6 changes: 1 addition & 5 deletions homeConfigurations/sway/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ in
XF86LaunchB = "exec $menu";
};

bars = [
{
statusCommand = "i3status-rs ~/.config/sway/status.toml";
}
];
bars = [ { statusCommand = "i3status-rs ~/.config/sway/status.toml"; } ];

# Sway specific

Expand Down
106 changes: 54 additions & 52 deletions homeConfigurations/terminal/default.nix
Original file line number Diff line number Diff line change
@@ -1,63 +1,65 @@
{ config, pkgs, inputs, ... }:
{
imports = [
inputs.nix-index-database.hmModules.nix-index
];
config,
pkgs,
inputs,
...
}:
{
imports = [ inputs.nix-index-database.hmModules.nix-index ];
# also wrap and install comma
programs.nix-index-database.comma.enable = true;

home.file.".inputrc".text = builtins.readFile ./inputrc;
home.packages = with pkgs; [
# TUI
tmate

# CLI stuff
bc
dnsutils
docker-compose
eternal-terminal
fd
file
gh
gopass
gnupg
h
jq
mdsh
psmisc
pwgen
ripgrep
ruby
shellcheck
shfmt
tree
unzip
webfs
wget
wl-clipboard

# Linux man pages!
man-pages

# Coding
inputs.self.packages.${pkgs.system}.myvim
go
gopls
(lowPrio gotools)

# Nix stuff
nix-update
nixpkgs-fmt
nixpkgs-review
]
++ (
with pkgs.gitAndTools; [
home.packages =
with pkgs;
[
# TUI
tmate

# CLI stuff
bc
dnsutils
docker-compose
eternal-terminal
fd
file
gh
gopass
gnupg
h
jq
mdsh
psmisc
pwgen
ripgrep
ruby
shellcheck
shfmt
tree
unzip
webfs
wget
wl-clipboard

# Linux man pages!
man-pages

# Coding
inputs.self.packages.${pkgs.system}.myvim
go
gopls
(lowPrio gotools)

# Nix stuff
nix-update
nixpkgs-fmt
nixpkgs-review
]
++ (with pkgs.gitAndTools; [
git-absorb
git-extras
git-gone
]
)
;
]);

nixpkgs.config.allowUnfree = true;

Expand Down
25 changes: 21 additions & 4 deletions nixosConfigurations/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{ self, inputs, ... }:
let
nixosSystem = args:
inputs.nixpkgs.lib.nixosSystem ({ specialArgs = { inherit inputs; }; } // args);
nixosSystem =
args:
inputs.nixpkgs.lib.nixosSystem (
{
specialArgs = {
inherit inputs;
};
}
// args
);
in
{
flake.nixosConfigurations = {
Expand All @@ -28,7 +36,13 @@ in
};

# This is the flake that contains the home-manager configuration
perSystem = { pkgs, lib, system, ... }:
perSystem =
{
pkgs,
lib,
system,
...
}:
let
# Only check the configurations for the current system
sysConfigs = lib.filterAttrs (_name: value: value.pkgs.system == system) self.nixosConfigurations;
Expand All @@ -43,6 +57,9 @@ in
'';

# Add all the nixos configurations to the checks
checks = lib.mapAttrs' (name: value: { name = "nixos-toplevel-${name}"; value = value.config.system.build.toplevel; }) sysConfigs;
checks = lib.mapAttrs' (name: value: {
name = "nixos-toplevel-${name}";
value = value.config.system.build.toplevel;
}) sysConfigs;
};
}
12 changes: 8 additions & 4 deletions nixosConfigurations/no1/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, inputs, pkgs, lib, ... }:
{
config,
inputs,
pkgs,
lib,
...
}:

{
imports = [
Expand Down Expand Up @@ -32,9 +38,7 @@
networking.hostName = "no1"; # Define your hostname.
networking.networkmanager.enable = true;

nix.nixPath = [
"nixpkgs=${toString pkgs.path}"
];
nix.nixPath = [ "nixpkgs=${toString pkgs.path}" ];
nix.settings.sandbox = "relaxed";

# Enable the OpenSSH daemon.
Expand Down
Loading

0 comments on commit 6b991b0

Please sign in to comment.