Skip to content

Commit

Permalink
ops: update code
Browse files Browse the repository at this point in the history
  • Loading branch information
romelBen committed Jul 22, 2024
1 parent 18b75e9 commit ea9f91d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 45 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ default: build
&& git remote set-url origin [email protected]:romelben/dotfiles

build: /nix /run/current-system/sw/bin/darwin-rebuild /opt/homebrew/bin/brew ~/.git
/run/current-system/sw/bin/nix --experimental-features 'nix-command flakes' build ./\#darwinConfigurations.$(shell hostname -s).system
./result/sw/bin/darwin-rebuild switch --flake .
/run/current-system/sw/bin/nix --experimental-features 'nix-command flakes' develop --command reload

update:
nix flake update
78 changes: 35 additions & 43 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.6)
{
description = "Nome: my Nix home";

Expand All @@ -12,22 +11,15 @@
nix-darwin = { url = "github:LnL7/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs"; };
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2405.*";
nuenv = { url = "https://flakehub.com/f/DeterminateSystems/nuenv/0.1.*"; inputs.nixpkgs.follows = "nixpkgs"; };
# uuidv7 = { url = "git+ssh://[email protected]/DeterminateSystems/uuidv7.git"; inputs.nixpkgs.follows = "nixpkgs"; };
};

outputs = inputs:
let
supportedSystems = [ "aarch64-darwin" ];
forEachSupportedSystem = f: inputs.nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ inputs.self.overlays.default ];
};
});

stateVersion = "24.05";
system = "aarch64-darwin";
username = "romelbenavides";
hostnameRaw = builtins.exec "scutil --get LocalHostName";
hostname = builtins.replaceStrings ["-"] ["_"] (builtins.trimString "." (builtins.replaceStrings [" "] ["_"] hostnameRaw));
caches = {
nixos-org = {
cache = "https://cache.nixos.org";
Expand All @@ -42,47 +34,47 @@
{
schemas = inputs.flake-schemas.schemas;

devShells = forEachSupportedSystem ({ pkgs }: {
default =
let
reload = pkgs.writeScriptBin "reload" ''
CONFIG_NAME=$(scutil --get LocalHostName)
FLAKE_OUTPUT=".#darwinConfigurations.''${CONFIG_NAME}.system"
${pkgs.nixFlakes}/bin/nix build "''${FLAKE_OUTPUT}" && \
./result/sw/bin/darwin-rebuild activate && \
${pkgs.zsh}/bin/zsh -c "source ${pkgs.homeDirectory}/.zshrc"
'';
in
pkgs.mkShell {
name = "playground";
packages = with pkgs; [
nixpkgs-fmt
reload
];
};
});
devShells = {
default = let
reload = inputs.nixpkgs.writeScriptBin "reload" ''
CONFIG_NAME=${hostname}
FLAKE_OUTPUT=".#darwinConfigurations.${CONFIG_NAME}.system"
${inputs.nixpkgs.nixFlakes}/bin/nix build "''${FLAKE_OUTPUT}" && \
./result/sw/bin/darwin-rebuild activate && \
${inputs.nixpkgs.zsh}/bin/zsh -c "source ${inputs.nixpkgs.homeDirectory}/.zshrc"
'';
in
inputs.nixpkgs.mkShell {
name = "playground";
packages = with inputs.nixpkgs; [
nixpkgs-fmt
reload
];
};
};

overlays.default = final: prev: {
inherit username system;
inherit username;
homeDirectory =
if (prev.stdenv.isDarwin)
then "/Users/${username}"
else "/home/${username}";
rev = inputs.self.rev or inputs.self.dirtyRev or null;
flake-checker = inputs.flake-checker.packages.${system}.default;
fh = inputs.fh.packages.${system}.default;
# uuidv7 = inputs.uuidv7.packages.${system}.default;
flake-checker = inputs.flake-checker.packages.aarch64-darwin.default;
fh = inputs.fh.packages.aarch64-darwin.default;
};

darwinConfigurations."${username}-${system}" = inputs.nix-darwin.lib.darwinSystem {
inherit system;
modules = [
inputs.nix.darwinModules.default
inputs.self.darwinModules.base
inputs.self.darwinModules.caching
inputs.home-manager.darwinModules.home-manager
inputs.self.darwinModules.home-manager
];
darwinConfigurations = {
"${hostname}" = inputs.nix-darwin.lib.darwinSystem {
inherit system;
modules = [
inputs.nix.darwinModules.default
inputs.self.darwinModules.base
inputs.self.darwinModules.caching
inputs.home-manager.darwinModules.home-manager
inputs.self.darwinModules.home-manager
];
};
};

darwinModules = {
Expand Down Expand Up @@ -115,4 +107,4 @@
templates = import
./templates;
};
}
}

0 comments on commit ea9f91d

Please sign in to comment.