Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add home-manager CI #220

Merged
merged 17 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/ci-home.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CI - Home
on:
push:
branches: [main]
paths:
- '.github/workflows/ci-home.yml'
- '**/home-manager/**.nix'
- 'Makefile.toml'
pull_request:
paths:
- '.github/workflows/ci-home.yml'
- '**/home-manager/**.nix'
- 'Makefile.toml'
schedule:
# Every 10:42 JST
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: '42 1 * * *'
workflow_dispatch:

jobs:
home-manager:
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- macos-13
home-manager-channel:
- release-23.05
- master # unstable nixpkgs
Comment on lines +29 to +31
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preparation for updating to unstable nixpkgs #147 (comment)

include:
- os: ubuntu-22.04
cleanup-script: |
rm '/home/runner/.config/nix/nix.conf'
rm '/home/runner/.config/home-manager/home.nix'
rm '/home/runner/.bashrc'
rm '/home/runner/.bash_logout'
- os: macos-13
# Latest macOS sets default shell as zsh, but having .bashrc except .bash_logout
cleanup-script: |
rm '/Users/runner/.config/nix/nix.conf'
rm '/Users/runner/.config/home-manager/home.nix'
rm '/Users/runner/.bashrc'

runs-on: ${{ matrix.os }}
steps:
- uses: DeterminateSystems/nix-installer-action@v4
- uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Register Nix Channels
run: |
nix-channel --add https://github.com/nix-community/home-manager/archive/${{ matrix.home-manager-channel }}.tar.gz home-manager
nix-channel --update
nix-channel --list
- run: nix-shell '<home-manager>' -A install
- name: Clean up conflict files with applying by home-manager
run: |
${{ matrix.cleanup-script }}
- uses: actions/checkout@v3
- run: home-manager switch -f ./home/.config/home-manager/user-github-actions.nix
- name: Print shell paths
run: |
which fish
which zsh
which bash # Be non nix shell
- name: Run customized dependencies
run: |
fish --command 'starship --version'
zsh -c 'bench_shells'
14 changes: 12 additions & 2 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ command = 'dist/deps'

[tasks.prepare-build]
command = 'mkdir'
args = ['-p', 'dist']
args = ['-p', 'dist/race']

[tasks.build]
dependencies = ['prepare-build']
Expand All @@ -56,10 +56,20 @@ args = [
'-v',
'-race',
'-o',
'dist',
'dist/race',
'./...',
]

[tasks.test]
dependencies = ['test-race']
command = 'home-manager'
args = [
'switch',
'-n', # dry-run
'-f',
'./home/.config/home-manager/home.nix',
]

[tasks.apply]
command = 'home-manager'
args = [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dotfiles

[![Linter Status](https://github.com/kachick/dotfiles/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/kachick/dotfiles/actions/workflows/lint.yml?query=branch%3Amain+)
[![Home Status](https://github.com/kachick/dotfiles/actions/workflows/ci-home.yml/badge.svg?branch=main)](https://github.com/kachick/dotfiles/actions/workflows/ci-home.yml?query=branch%3Amain+)
[![Nix Status](https://github.com/kachick/dotfiles/actions/workflows/ci-nix.yml/badge.svg?branch=main)](https://github.com/kachick/dotfiles/actions/workflows/ci-nix.yml?query=branch%3Amain+)

Personal dotfiles that can be placed in the public repository
Expand Down
6 changes: 2 additions & 4 deletions home/.config/home-manager/home.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{ config, pkgs, ... }:
{ config, pkgs, lib, ... }:

# FAQ
# - How to get sha256? => assume by `lib.fakeSha256`

{
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "kachick";
home.username = lib.mkDefault "kachick";
# TODO: How to cover lima? The default is /home/kachick.local
home.homeDirectory = if pkgs.stdenv.hostPlatform.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}";

Expand Down
6 changes: 6 additions & 0 deletions home/.config/home-manager/user-github-actions.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ ... }:

{
imports = [ ./home.nix ];
home.username = "runner";
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be put outsides the home/, but actually not installed into machines, so acceptable for now... 😩