From ea9f91d779fde9342e5c1ec4d71a3cc8340d4855 Mon Sep 17 00:00:00 2001 From: Romel Benavides Date: Sun, 21 Jul 2024 19:37:17 -0500 Subject: [PATCH] ops: update code --- Makefile | 3 +-- flake.nix | 78 +++++++++++++++++++++++++------------------------------ 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index 8a754ae..79d24e8 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,7 @@ default: build && git remote set-url origin git@github.com: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 \ No newline at end of file diff --git a/flake.nix b/flake.nix index 2029b5a..f7acefa 100644 --- a/flake.nix +++ b/flake.nix @@ -1,4 +1,3 @@ -# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.6) { description = "Nome: my Nix home"; @@ -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://git@github.com/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"; @@ -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 = { @@ -115,4 +107,4 @@ templates = import ./templates; }; -} +} \ No newline at end of file