diff --git a/.github/workflows/nix-checks.yml b/.github/workflows/nix-checks.yml new file mode 100644 index 0000000..c566db1 --- /dev/null +++ b/.github/workflows/nix-checks.yml @@ -0,0 +1,34 @@ +name: nix-checks + +on: + push: + pull_request: + +jobs: + flake-check: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Nix (macOS) + if: runner.os == 'macOS' + run: | + set -euo pipefail + if [ -x /nix/var/nix/profiles/default/bin/nix ]; then + echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH" + exit 0 + fi + curl -fsSL https://install.determinate.systems/nix | sh -s -- install --no-confirm + echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH" + - name: Install Nix (Linux) + if: runner.os == 'Linux' + uses: cachix/install-nix-action@v27 + - name: Nix flake check + env: + NIX_CONFIG: | + experimental-features = nix-command flakes + access-tokens = github.com=${{ github.token }} + run: nix flake check --accept-flake-config diff --git a/README.org b/README.org index 2ec016f..71c1742 100644 --- a/README.org +++ b/README.org @@ -30,6 +30,9 @@ Keyword: macOS, Xcode, Homebrew, Emacs, Zsh ./scripts/devcontainer-check.sh #+end_src +** CI +- GitHub Actions runs =nix flake check= on Ubuntu and macOS for every push and PR. + ** Legacy (stow + dotnet-script) #+begin_src sh /bin/zsh -c "$(curl -fsSL https://raw.githubusercontent.com/hiroakit/xcclt/HEAD/xcclt.sh)" && git clone https://github.com/hiroakit/profile --recursive && cd profile && sh install.sh diff --git a/flake.nix b/flake.nix index 2365319..2193e8e 100644 --- a/flake.nix +++ b/flake.nix @@ -50,10 +50,14 @@ ./nix/darwin.nix home-manager.darwinModules.home-manager { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { inherit inputs hostConfig; }; - home-manager.users.${username} = import ./nix/home.nix; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { inherit inputs hostConfig; }; + home-manager.users.${username} = { ... }: { + imports = [ ./nix/home.nix ]; + home.username = username; + home.homeDirectory = "/Users/${username}"; + }; } ]; }; @@ -62,9 +66,9 @@ darwinConfigurations.${hostConfig.darwinHost} = mkDarwin hostConfig.darwinSystem; - homeConfigurations.${username}@${hostConfig.wslHost} = + homeConfigurations."${username}@${hostConfig.wslHost}" = mkHome hostConfig.wslSystem; - homeConfigurations.${devcontainerHost.username}@${devcontainerHost.wslHost} = + homeConfigurations."${devcontainerHost.username}@${devcontainerHost.wslHost}" = mkHomeWith { system = devcontainerHost.wslSystem; hostCfg = devcontainerHost; }; checks = lib.genAttrs diff --git a/nix/darwin.nix b/nix/darwin.nix index 6c40ee9..e255002 100644 --- a/nix/darwin.nix +++ b/nix/darwin.nix @@ -1,6 +1,7 @@ -{ config, pkgs, ... }: +{ config, pkgs, hostConfig, ... }: { system.stateVersion = 4; nix.settings.experimental-features = [ "nix-command" "flakes" ]; programs.zsh.enable = true; + users.users.${hostConfig.username}.home = "/Users/${hostConfig.username}"; }