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

refactor: align architecture with srid/nixos-config #7

Merged
merged 25 commits into from
Sep 10, 2023

Conversation

cameronraysmith
Copy link
Contributor

@cameronraysmith cameronraysmith commented Sep 8, 2023

The purpose of this PR is to increase the similarity between the structure of nix-dev-home and srid/nixos-config to support comprehension of the abstraction that arises with multiple systems, beyond home-manager, etc.

Briefly, the proposed updates include:

  • addition of a minimal justfile with io/update/lint/check/dev/build/clean/run recipes
  • migration of the home-manager default config from ./flake.nix to ./home/default.nix
  • migration of the terminal configuration from ./flake.nix to ./home/terminal.nix
  • import of the starship config directly from srid/nixos-config as previously alluded to in the code comment
  • use of github:nix-systems/default to import systems
  • refactoring of flake.nix accordingly
  • setting the default username to runner for compatibility with debugging and testing in github actions runners
    • see here for example
  • addition of .envrc and dev shell
  • update of README.md to account for these changes
  • update of flake.lock

@cameronraysmith cameronraysmith marked this pull request as ready for review September 8, 2023 21:47
- use `systems.url = "github:nix-systems/default";`
- migrate default, terminal, starship configs to ./home
- set default username to "runner" for compatibility with debugging in github actions
Copy link
Member

@srid srid left a comment

Choose a reason for hiding this comment

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

I see you've updated the inputs (ac0f230); is this tested on a mac?

flake.nix Outdated Show resolved Hide resolved
home/terminal.nix Outdated Show resolved Hide resolved
home/terminal.nix Outdated Show resolved Hide resolved
justfile Outdated Show resolved Hide resolved
cameronraysmith added a commit to cameronraysmith/nixos-unified-template that referenced this pull request Sep 8, 2023
cameronraysmith added a commit to cameronraysmith/nixos-unified-template that referenced this pull request Sep 8, 2023
cameronraysmith added a commit to cameronraysmith/nixos-unified-template that referenced this pull request Sep 8, 2023
cameronraysmith added a commit to cameronraysmith/nixos-unified-template that referenced this pull request Sep 8, 2023
@cameronraysmith
Copy link
Contributor Author

I see you've updated the inputs (ac0f230); is this tested on a mac?

check, update, fmt yes, but I will create a new user and verify everything is working as expected from scratch

@cameronraysmith
Copy link
Contributor Author

cameronraysmith commented Sep 8, 2023

Creating a fresh user named runner on my M1 macbook, covering aarch64-darwin, this is the approximate user experience I am seeing on a DeterminateSystems nix install without nix-darwin:

flake init
> nix flake init -t github:cameronraysmith/nix-dev-home/refactor/like-nixos-config
wrote: /Users/runner/test/home/terminal.nix
wrote: /Users/runner/test/home/starship.nix
wrote: /Users/runner/test/home/default.nix
wrote: /Users/runner/test/home/neovim/haskell.nix
wrote: /Users/runner/test/home/neovim/coc.nix
wrote: /Users/runner/test/home/neovim/telescope.nix
wrote: /Users/runner/test/home/neovim/config.lua
wrote: /Users/runner/test/home/neovim/which-key.nix
wrote: /Users/runner/test/home/neovim/default.nix
wrote: /Users/runner/test/home/neovim
wrote: /Users/runner/test/home
wrote: /Users/runner/test/flake.lock
wrote: /Users/runner/test/justfile
wrote: /Users/runner/test/.gitignore
wrote: /Users/runner/test/flake.nix
wrote: /Users/runner/test/.github/workflows/ci.yaml
wrote: /Users/runner/test/.github/workflows/flakehub-publish-rolling.yml
wrote: /Users/runner/test/.github/workflows
wrote: /Users/runner/test/.github

> tree --du -h
[ 15K]  .
├── [3.0K]  flake.lock
├── [2.3K]  flake.nix
├── [8.7K]  home
│   ├── [ 345]  default.nix
│   ├── [6.0K]  neovim
│   │   ├── [ 156]  coc.nix
│   │   ├── [ 591]  config.lua
│   │   ├── [1.8K]  default.nix
│   │   ├── [1.0K]  haskell.nix
│   │   ├── [1.6K]  telescope.nix
│   │   └── [ 639]  which-key.nix
│   ├── [ 604]  starship.nix
│   └── [1.6K]  terminal.nix
└── [ 643]  justfile

  29K used in 3 directories, 12 files
just run
machine% just run
nix fmt
warning: Git tree '/Users/runner/nix-dev-home' is dirty
0 / 10 have been reformatted
nix flake check
warning: Git tree '/Users/runner/nix-dev-home' is dirty
warning: unknown flake output 'nixos-flake'
warning: unknown flake output 'homeModules'
trace: warning: optionsDocBook is deprecated since 23.11 and will be removed in 24.05
trace: warning: optionsDocBook is deprecated since 23.11 and will be removed in 24.05
trace: warning: optionsDocBook is deprecated since 23.11 and will be removed in 24.05
warning: The check omitted these incompatible systems: aarch64-linux, x86_64-darwin, x86_64-linux
Use '--all-systems' to check all.
nix run
warning: Git tree '/Users/runner/nix-dev-home' is dirty
+ nix run '.#homeConfigurations."runner".activationPackage'
warning: Git tree '/Users/runner/nix-dev-home' is dirty
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLaunchAgents
Activating checkLinkTargets
Activating writeBoundary
Activating linkGeneration
Cleaning up orphan links from /Users/runner
No change so reusing latest profile generation 1
Creating home file links in /Users/runner
Activating batCache
No themes were found in '/Users/runner/.config/bat/themes', using the default set
No syntaxes were found in '/Users/runner/.config/bat/syntaxes', using the default set.
Writing theme set to /Users/runner/.cache/bat/themes.bin ... okay
Writing syntax set to /Users/runner/.cache/bat/syntaxes.bin ... okay
Writing metadata to folder /Users/runner/.cache/bat ... okay
Activating copyFonts
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
Activating onFilesChange
Activating setupLaunchAgents

machine% zsh
zsh compinit: insecure directories and files, run compaudit for list.
Ignore insecure directories and files and continue [y] or abort compinit [n]? y

runner on machine nix-dev-home on  refactor/like-nixos-config [$] 
❯ ls -alh $HOME | grep '^l'
lrwxr-xr-x   1 runner staff  76 Sep  8 19:08 .bash_profile -> /nix/store/7627b2zkn3mxg8pvagldzjbvcnswawxp-home-manager-files/.bash_profile
lrwxr-xr-x   1 runner staff  70 Sep  8 19:08 .bashrc -> /nix/store/7627b2zkn3mxg8pvagldzjbvcnswawxp-home-manager-files/.bashrc
lrwxr-xr-x   1 runner staff  47 Sep  8 18:56 .nix-profile -> /Users/runner/.local/state/nix/profiles/profile
lrwxr-xr-x   1 runner staff  71 Sep  8 19:08 .profile -> /nix/store/7627b2zkn3mxg8pvagldzjbvcnswawxp-home-manager-files/.profile
lrwxr-xr-x   1 runner staff  70 Sep  8 19:08 .zshenv -> /nix/store/7627b2zkn3mxg8pvagldzjbvcnswawxp-home-manager-files/.zshenv
lrwxr-xr-x   1 runner staff  69 Sep  8 19:08 .zshrc -> /nix/store/7627b2zkn3mxg8pvagldzjbvcnswawxp-home-manager-files/.zshrc

runner on machine nix-dev-home on  refactor/like-nixos-config [$] 
❯ tree --du -ah $HOME/.config 
[1008]  /Users/runner/.config
├── [ 245]  coc
│   ├── [ 115]  extensions
│   │   └── [  19]  package.json
│   └── [   2]  memos.json
├── [ 182]  direnv
│   └── [  86]  direnvrc -> /nix/store/7627b2zkn3mxg8pvagldzjbvcnswawxp-home-manager-files/.config/direnv/direnvrc
├── [ 305]  nvim
│   ├── [  93]  coc-settings.json -> /nix/store/7627b2zkn3mxg8pvagldzjbvcnswawxp-home-manager-files/.config/nvim/coc-settings.json
│   └── [  84]  init.lua -> /nix/store/7627b2zkn3mxg8pvagldzjbvcnswawxp-home-manager-files/.config/nvim/init.lua
└── [  84]  starship.toml -> /nix/store/7627b2zkn3mxg8pvagldzjbvcnswawxp-home-manager-files/.config/starship.toml

 1.2K used in 5 directories, 6 files

OR with echo "use flake" > .envrc

direnv
machine% zsh
zsh compinit: insecure directories and files, run compaudit for list.
Ignore insecure directories and files and continue [y] or abort compinit [n]? y
direnv: loading ~/nix-dev-home/.envrc                                                                                                                          
direnv: using flake
direnv: nix-direnv: using cached dev shell
direnv: export +CONFIG_SHELL +HOST_PATH +IN_NIX_SHELL +MACOSX_DEPLOYMENT_TARGET +NIX_BUILD_CORES +NIX_CFLAGS_COMPILE +NIX_DONT_SET_RPATH +NIX_DONT_SET_RPATH_FOR_BUILD +NIX_ENFORCE_NO_NATIVE +NIX_IGNORE_LD_THROUGH_GCC +NIX_NO_SELF_RPATH +NIX_STORE +PATH_LOCALE +SOURCE_DATE_EPOCH +XDG_DATA_DIRS +__darwinAllowLocalNetworking +__impureHostDeps +__propagatedImpureHostDeps +__propagatedSandboxProfile +__sandboxProfile +__structuredAttrs +buildCommandPath +buildInputs +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +dontAddDisableDepTrack +enableParallelBuilding +enableParallelChecking +enableParallelInstalling +mesonFlags +name +nativeBuildInputs +out +outputs +passAsFile +patches +preferLocalBuild +propagatedBuildInputs +propagatedNativeBuildInputs +shell +stdenv +strictDeps +system ~PATH

runner on machine nix-dev-home on  refactor/like-nixos-config [$!?] via ❄️  impure (home-manager-generation-env) 
❯

An equivalent experience is verified in this debian slim container image on M1 macbook (covering aarch64-linux) and in a github actions ubuntu runner (covering x86_64-linux). I have not tested x86_64-darwin.

flake.nix Outdated Show resolved Hide resolved
home/default.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
.envrc Outdated Show resolved Hide resolved
@cameronraysmith
Copy link
Contributor Author

I believe I am finished with my editing. Unless you have any comments on the readme, feel free to merge from my perspective.

@srid
Copy link
Member

srid commented Sep 10, 2023

Great, thanks.

@srid srid merged commit 049e533 into juspay:main Sep 10, 2023
1 check passed
@cameronraysmith
Copy link
Contributor Author

Thanks so much for the reviews @srid !

@srid srid mentioned this pull request Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

should factoring, imports, and directory tree mirror srid/nixos-config?
2 participants