Skip to content

Instantly share code, notes, and snippets.

@aduh95
Last active May 18, 2025 19:32
Show Gist options
  • Save aduh95/affe5ba977acaaa8f480bc7d98161ec9 to your computer and use it in GitHub Desktop.
Save aduh95/affe5ba977acaaa8f480bc7d98161ec9 to your computer and use it in GitHub Desktop.

Getting started

On macOS

  1. Install Nix.

  2. Install Home manager – I recommend using the unstable channel version.

  3. Update ~/.config/home-manager/home.nix to something like (don't forget to change the home.username value):

    { config, lib, pkgs, ... }:
    
    let
      gist = builtins.fetchurl {
        url = "https://gist.github.com/aduh95/affe5ba977acaaa8f480bc7d98161ec9/raw/home.nix";
        sha256 = lib.fakeHash;
      };
      importedGist = (import "${gist}") { inherit config; inherit lib; inherit pkgs; };
    in
    {
      # Home Manager needs a bit of information about you and the
      # paths it should manage.
      home.username = "TODO";
      home.homeDirectory = "/Users/${home.username}";
      home.stateVersion = importedGist.home.stateVersion;
      home.packages = importedGist.home.packages;
    
      home.sessionPath = [
        "/nix/var/nix/profiles/default/bin"
        "$HOME/.nix-profile/bin"
      ];
      home.sessionVariables = {
        EDITOR = "vim";
      };
    
      inherit (importedGist) programs;
    }
  4. Run nix-channel --update && home-manager switch. It should complain about unmatched hash. Replace lib.fakeHash by the correct hash on line 6.

  5. Run nix-channel --update && home-manager switch again.

  6. Open a new shell. Voilà, you're all set.

On NixOS

Edit /etc/nixos/configuration.nix with (replace TODO with your actual user handle):

let
  home-manager = builtins.fetchTarball https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz;
  gist = builtins.fetchurl {
    url = "https://gist.github.com/aduh95/affe5ba977acaaa8f480bc7d98161ec9/raw/home.nix";
    sha256 = pkgs.lib.fakeHash;
  };
in
{
    # …
    imports = [
        # …
        (import "${home-manager}/nixos")
    ];
    # …
    home-manager.users.TODO = import "${gist}";
}

Run nixos-build switch, replace the hash, re-run it, and voilà.

{ config, lib, pkgs, ... }:
{
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"mongodb-ce"
];
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "25.05";
home.packages = [
pkgs.curl
pkgs.deno
pkgs.jq # JSON stream parser
pkgs.mpv-unwrapped # VLC like
pkgs.nodejs-slim
pkgs.ollama # LLM stuff
pkgs.transmission_4 # Torrenting
# Fonts
pkgs.fira-code
] ++ pkgs.lib.optionals (! pkgs.stdenv.buildPlatform.isDarwin) [
# Packages that are included in xcode-select
pkgs.git
pkgs.neovim
pkgs.python3
] ++ [
(pkgs.writeShellScriptBin "npx" "exec corepack npx \"$@\"")
];
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.direnv = {
enable = true;
enableZshIntegration = true;
nix-direnv.enable = true;
};
programs.gh = {
enable = true;
settings = {
# Workaround for https://github.com/nix-community/home-manager/issues/4744
version = 1;
editor = "vi";
aliases = {
co = "pr checkout";
pv = "pr view";
};
};
};
programs.gpg = {
enable = true;
settings = {
auto-key-retrieve = true;
no-emit-version = true;
};
};
programs.vscode = {
enable = true;
package = pkgs.vscodium;
profiles.default = {
extensions = with pkgs.vscode-extensions; [
streetsidesoftware.code-spell-checker
streetsidesoftware.code-spell-checker-french
github.vscode-github-actions
bbenoist.nix
teabyii.ayu
tomoki1207.pdf
vscodevim.vim
waderyan.gitblame
];
userSettings = {
"cSpell.language" = "en,fr";
"diffEditor.ignoreTrimWhitespace" = false;
"editor.fontFamily" = "'Fira Code'";
"editor.fontLigatures" = true;
"editor.fontSize" = 20;
"editor.inlineSuggest.enabled" = true;
"editor.lineNumbers" = "on";
"editor.mouseWheelZoom" = false;
"editor.renderLineHighlight" = "gutter";
"files.autoSave" = "onFocusChange";
"git.allowNoVerifyCommit" = true;
"git.branchProtectionPrompt" = "alwaysCommit";
"git.enableStatusBarSync" = false;
"git.inputValidation" = true;
"git.pullTags" = false;
"git.terminalAuthentication" = false;
"gitblame.delayBlame" = 500;
"gitblame.inlineMessageEnabled" = true;
"terminal.integrated.fontSize" = 16;
"typescript.updateImportsOnFileMove.enabled" = "never";
"window.autoDetectColorScheme" = true;
"window.zoomLevel" = -2;
"workbench.colorTheme" = "Ayu Dark";
"workbench.preferredDarkColorTheme" = "Ayu Dark";
};
};
};
programs.zsh = {
enable = true;
autosuggestion = {
enable = true;
};
defaultKeymap = "viins";
oh-my-zsh = {
enable = true;
theme = "robbyrussell";
};
syntaxHighlighting = {
enable = true;
};
sessionVariables = {};
shellAliases = {
# Frequent typos
gti = "git";
igt = "git";
flush-dns = if pkgs.stdenv.buildPlatform.isDarwin then "sudo killall -HUP mDNSResponder" else "sudo resolvectl flush-caches";
# Corepack aliases (for Node.js package manager versioning)
pnpm = "corepack pnpm";
yarn = "corepack yarn";
# Update all global dependencies
maj = "nix-channel --update && home-manager switch";
remote-node-push-cmd = "awk -F: '{ print \"gitpushto [email protected]:\" $1 \"/node.git \" $2 \" -f\" }' <<<";
};
initContent = ''
gitpushto() {
remote=$1
branch=$2
shift 2
git push "$remote" "HEAD:refs/heads/$branch" $@
}
gitpushtoGH() {
remote="''${1%%:*}"
branch="''${1#*:}"
shift
gitpushto "$remote" "$branch" $@
}
npm() {
command npm "$@" || {
EXIT_CODE=$?
[ "$EXIT_CODE" = 127 ] && corepack npm "$@" || return "$EXIT_CODE"
}
}
bindkey -v
'';
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment