Skip to content

Commit

Permalink
switch to nixfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
macalinao committed Nov 13, 2024
1 parent e29e584 commit a51442d
Show file tree
Hide file tree
Showing 39 changed files with 714 additions and 431 deletions.
2 changes: 1 addition & 1 deletion config/vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"svg.preview.mode": "svg",
"nix.enableLanguageServer": true,
"settingsSync.ignoredSettings": ["-rust-analyzer.server.path"],
"nixfmt.path": "nixpkgs-fmt",
"nixfmt.path": "nixfmt",
"terminal.integrated.tabs.hideCondition": "singleGroup",
"[properties]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
Expand Down
10 changes: 7 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { flake-utils, nixpkgs, ... }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{ flake-utils, nixpkgs, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
formatter = pkgs.nixfmt-rfc-style;
devShells.default = import ./nix/shells/nix.nix { inherit pkgs; };
});
}
);
}
15 changes: 12 additions & 3 deletions nix/darwin/default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:

let
homeBase = import ../home { systemConfig = config; };
mode = config.igm.mode;
in
with lib; {
with lib;
{
environment.systemPackages = with pkgs; [
vim
# Tor install is currently broken 2023-11-28
Expand Down Expand Up @@ -36,7 +42,10 @@ with lib; {
configureBuildUsers = true;
settings = {
sandbox = false;
trusted-users = [ "root" "igm" ];
trusted-users = [
"root"
"igm"
];
};
extraOptions = ''
experimental-features = nix-command flakes
Expand Down
97 changes: 54 additions & 43 deletions nix/darwin/homebrew.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ let
mode = config.igm.mode;
isM1 = config.igm.isM1;
in
with lib; rec {
with lib;
rec {

enable = true;

Expand All @@ -33,47 +34,57 @@ with lib; rec {
"source-foundry/taproom"
];

brews = (lib.optionals (!isM1) [ "openssl" "[email protected]" ]) ++ [
"yabai"
"skhd"
"sui"
];
brews =
(lib.optionals (!isM1) [
"openssl"
"[email protected]"
])
++ [
"yabai"
"skhd"
"sui"
];

casks = [
"android-studio"
"anki"
"arc"
"brave-browser"
# "dashlane"
"discord"
"docker"
"figma"
"google-chrome"
"keybase"
"linear-linear"
"ngrok"
"notion"
"numi"
"postman"
"private-internet-access"
"raycast"
"slack"
"sourcefoundry-slice"
"spaceid"
"spotify"
"tableplus"
"the-unarchiver"
"zoom"
] ++ (lib.optionals (mode == "personal") ([
"google-drive"
"ledger-live"
"obsidian"
"signal"
"telegram"
"tor-browser"
"transmission"
"vlc"
"wechat"
"whatsapp@beta"
] ++ games));
casks =
[
"android-studio"
"anki"
"arc"
"brave-browser"
# "dashlane"
"discord"
"docker"
"figma"
"google-chrome"
"keybase"
"linear-linear"
"ngrok"
"notion"
"numi"
"postman"
"private-internet-access"
"raycast"
"slack"
"sourcefoundry-slice"
"spaceid"
"spotify"
"tableplus"
"the-unarchiver"
"zoom"
]
++ (lib.optionals (mode == "personal") (
[
"google-drive"
"ledger-live"
"obsidian"
"signal"
"telegram"
"tor-browser"
"transmission"
"vlc"
"wechat"
"whatsapp@beta"
]
++ games
));
}
160 changes: 99 additions & 61 deletions nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,84 +21,116 @@
};

outputs =
{ nixpkgs
, home-manager
, darwin
, vscode-server
, saber-overlay
, flake-utils
, rnix-lsp
, ...
{
nixpkgs,
home-manager,
darwin,
vscode-server,
saber-overlay,
flake-utils,
rnix-lsp,
...
}:
let
mkPrivate = import ./private;

mkNixosSystem = { modules, additionalOverlays ? [ ], igm ? { } }:
mkNixosSystem =
{
modules,
additionalOverlays ? [ ],
igm ? { },
}:
let
system = "x86_64-linux";
in
nixpkgs.lib.nixosSystem {
inherit system;
modules = [
({ ... }: {
inherit igm;
})
({ ... }: {
imports = [ "${vscode-server}/default.nix" ];
})
(
{ ... }:
{
inherit igm;
}
)
(
{ ... }:
{
imports = [ "${vscode-server}/default.nix" ];
}
)
(import ./system.nix {
isLinux = true;
})
home-manager.nixosModules.home-manager
({
nixpkgs = import ./nixpkgs/config.nix {
additionalOverlays = [ saber-overlay.overlays.default ] ++ additionalOverlays ++ [
(self: super: {
rnix-lsp = rnix-lsp.defaultPackage.${system};
})
];
additionalOverlays =
[ saber-overlay.overlays.default ]
++ additionalOverlays
++ [
(self: super: {
rnix-lsp = rnix-lsp.defaultPackage.${system};
})
];
};
})
] ++ modules;
};

mkDarwinSystem = { isM1 ? false, additionalOverlays ? [ ], modules ? [ ], computerName, hostName }:
mkDarwinSystem =
{
isM1 ? false,
additionalOverlays ? [ ],
modules ? [ ],
computerName,
hostName,
}:
let
system = if isM1 then "aarch64-darwin" else "x86_64-darwin";
in
darwin.lib.darwinSystem {
inherit system;
modules = [
({ ... }:
modules =
[
(
{ ... }:
{
igm = {
inherit isM1;
mode = "personal";
};
nixpkgs = import ./nixpkgs/config.nix {
isDarwin = true;
additionalOverlays =
[ saber-overlay.overlays.default ]
++ additionalOverlays
++ [
(self: super: {
rnix-lsp = rnix-lsp.defaultPackage.${system};
})
];
};
}
)
(import ./system.nix { isDarwin = true; })
home-manager.darwinModules.home-manager
]
++ modules
++ [
{
igm = {
inherit isM1;
mode = "personal";
networking = {
inherit computerName hostName;
localHostName = hostName;
};
nixpkgs = import ./nixpkgs/config.nix {
isDarwin = true;
additionalOverlays = [ saber-overlay.overlays.default ] ++ additionalOverlays ++ [
(self: super: {
rnix-lsp = rnix-lsp.defaultPackage.${system};
})
];
};
})
(import ./system.nix { isDarwin = true; })
home-manager.darwinModules.home-manager
] ++ modules ++ [
{
networking = {
inherit computerName hostName;
localHostName = hostName;
};
services.nix-daemon.enable = true;
}
];
services.nix-daemon.enable = true;
}
];
};
in
{
lib = { inherit mkNixosSystem mkDarwinSystem mkPrivate; };
lib = {
inherit mkNixosSystem mkDarwinSystem mkPrivate;
};
nixosConfigurations.ci-home = mkNixosSystem {
igm = {
pure = true;
Expand Down Expand Up @@ -136,7 +168,8 @@
computerName = "igm-darwin-ci-m1";
hostName = "igm-darwin-ci-m1";
};
} // (
}
// (
let
supportedSystems = [
"aarch64-linux"
Expand All @@ -147,24 +180,29 @@
"x86_64-linux"
];
in
(flake-utils.lib.eachSystem supportedSystems
(system:
(flake-utils.lib.eachSystem supportedSystems (
system:
let
nixpkgs-config-public = (import ./nixpkgs/config.nix rec {
isDarwin = nixpkgs.legacyPackages.${system}.lib.hasSuffix "-darwin" system;
nixpkgs-config-public = (
import ./nixpkgs/config.nix rec {
isDarwin = nixpkgs.legacyPackages.${system}.lib.hasSuffix "-darwin" system;

# There are lots of wrongfully broken packages on Darwin
# https://github.com/NixOS/nixpkgs/pull/173671
allowBroken = isDarwin;
});
pkgs = import nixpkgs
{
# There are lots of wrongfully broken packages on Darwin
# https://github.com/NixOS/nixpkgs/pull/173671
allowBroken = isDarwin;
}
);
pkgs =
import nixpkgs {
inherit system;
inherit (nixpkgs-config-public) config overlays;
} // saber-overlay.packages.${system};
}
// saber-overlay.packages.${system};
in
rec {
{
formatter = pkgs.nixfmt-rfc-style;
packages = import ./shells { inherit pkgs; };
}))
}
))
);
}
Loading

0 comments on commit a51442d

Please sign in to comment.