Skip to content

Commit

Permalink
docs: non-flake, channels example
Browse files Browse the repository at this point in the history
  • Loading branch information
hraban committed Nov 12, 2024
1 parent d7282ae commit e262abe
Showing 1 changed file with 79 additions and 6 deletions.
85 changes: 79 additions & 6 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,52 @@ It works in [[https://github.com/nix-community/home-manager][home-manager]] and

Home-manager and nix-darwin aren’t either-or: you can have both, and you can install .app bundles on your mac through both (some user specific using home-manager, some system wide using nix-darwin). In that case you’d want to load both the nix-darwin module, and the home-manager module at the same time in their respective configurations.

*** Flakes, home-manager through nix-darwin
*** Flakes, just home-manager

Only using home-manager, no nix-darwin (yet)? You can import the home-manager module directly:

#+begin_src nix
{
description = "Minimal Flake for macOS with home-manager and mac-app-util";

inputs = {
mac-app-util.url = "github:hraban/mac-app-util";
};

outputs = { self, nixpkgs, home-manager, mac-app-util, ... }: let
username = "jdoe";
system = "aarch64-darwin";
in {
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
modules = [
mac-app-util.homeManagerModules.default
({ pkgs, ... }: {
home = {
inherit username;
homeDirectory = "/Users/${username}";
# This is where you would install any programs as usual:
packages = with pkgs; [
ripgrep
vim

# What mac-app-util does for you, is that you can also just
# install derivations here which have a `/Applications/`
# directory, and it will be available in Spotlight and in your App
# Launcher, no further configuration needed:
vscode
iterm2
];
stateVersion = "24.05";
};
})
];
};
};
}
#+end_src

*** Flakes, nix-darwin (with or without home-manager)

#+begin_src nix
{
Expand Down Expand Up @@ -63,11 +108,9 @@ Home-manager and nix-darwin aren’t either-or: you can have both, and you can i
}
#+end_src

*** Non-flakes
*** Non-flakes, aka “channels”

Since I use flakes for home manager and nix-darwin I’m not 100% on how to do this, but I suspect that it’s similar to the above, at its core.

What will be different is the “plumbing”, i.e. how to get a reference to this app’s derivation. Here’s how:
This is similar to the above. What will be different is the “plumbing”, i.e. how to get a reference to this app’s derivation. Here’s how:

#+begin_src nix
let
Expand All @@ -92,7 +135,37 @@ mac-app-util.homeManagerModules.default
mac-app-util.darwinModules.default
#+end_src

The rest is up to you. Good luck!
Example using the above:

#+begin_src nix
{ config, pkgs, ... }:

let
mac-app-util-src = pkgs.fetchFromGitHub {
repo = "mac-app-util";
owner = "hraban";
rev = "...";
hash = "";
};
mac-app-util = (pkgs.callPackage mac-app-util-src {});
in

{
home = {
username = "jdoe";
homeDirectory = "/Users/jdoe";
stateVersion = "24.05";
packages = with pkgs; [
vscode
iterm2
];
};
imports = [
mac-app-util.homeManagerModules.default
];
}
#+end_src

** Commands

At the core of this project is a (Nix-agnostic) program that can:
Expand Down

0 comments on commit e262abe

Please sign in to comment.