-
Notifications
You must be signed in to change notification settings - Fork 3
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
How to add nixcasks to pkgs? #4
Comments
I don't have an answer since I am very much in the same situation. I've been trying to figure it out by looking at these dotfiles and these dotfiles but haven't had any luck with it yet. Granted, I also am still new to nix, so I may be missing something obvious. |
This reminds me that I should document the project better. :-) In case of @dvonessen 's config, I'd add it to package overrides like this: pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
config.packageOverrides = _: {
nixcasks = inputs.nixcasks.legacyPackages."${system}";
}
overlays = [
nur.overlay
nixpkgs-firefox-darwin.overlay
nix-vscode-extensions.overlays.default
];
}; or even better like this: pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
config.packageOverrides = _: {
nixcasks = import inputs.nixcasks {
inherit nixpkgs;
pkgs = import nixpkgs {};
osVersion = "monterey";
};
}
overlays = [
nur.overlay
nixpkgs-firefox-darwin.overlay
nix-vscode-extensions.overlays.default
];
}; In this second form, the OS version is used to choose a correct alternative in case the Cask in question provides it; this is not yet supported on (Note: as my config is quite different, I didn't test these exact snippets; I'm also using this in Home Manager, not in nix-darwin) You may also write an overlay, but I find package overrides simpler and more than enough for this use case. |
Could you also post an example of a configuration with Home Manager? I think that would be really useful. |
Sure, here's my flake.nix, my macOS hostname is {
description = "Home Manager configuration of jsz";
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
impermanence.url = "github:nix-community/impermanence";
nurrepo.url = "github:nix-community/NUR";
nerdy.url = "github:GenericNerdyUsername/nixpkgs/c6944a78e5edf4341df9518045ab1d723e4c4f5a";
flake-utils.url = "github:numtide/flake-utils";
nixcasks = {
url = "/Users/jsz/Devel/jacekszymanski/nixcasks";
inputs.nixpkgs.follows = "nixpkgs";
};
jacekszymanski = {
url = "github:jacekszymanski/nur-packages";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-vscode-extensions = {
url = "github:nix-community/nix-vscode-extensions";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-homebrew = {
url = "github:zhaofengli-wip/nix-homebrew";
inputs = {
nixpkgs.follows = "nixpkgs";
nix-darwin.follows = "darwin";
flake-utils.follows = "flake-utils";
};
};
homebrew-core = {
url = "github:homebrew/homebrew-core";
flake = false;
};
homebrew-cask = {
url = "github:homebrew/homebrew-cask";
flake = false;
};
};
outputs =
{ nixpkgs
, home-manager
, nurrepo
, jacekszymanski
, nerdy
, nix-vscode-extensions
, nixpkgs-unstable
, impermanence
, darwin
, nix-homebrew
, ... } @ inputs:
let
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
];
overlay-unstable = final: prev: {
unstable = import nixpkgs-unstable {
inherit (prev) system;
config.allowUnfree = true;
};
};
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
stuff = forAllSystems (system: rec {
nurpkgs = import nixpkgs { inherit system; };
nerdyjetbrains = (import nerdy { inherit system; }).jetbrains;
nur = import nurrepo {
inherit pkgs nurpkgs;
repoOverrides = { jacekszymanski = import jacekszymanski { inherit pkgs nixpkgs; }; };
};
vscode-exts = nix-vscode-extensions.extensions."${system}";
nixcasks = import inputs.nixcasks {
inherit pkgs nixpkgs;
osVersion = "monterey";
};
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
config.packageOverrides = prev: {
inherit nur vscode-exts nixcasks;
jetbrains = nerdyjetbrains;
};
};
});
in {
nixosConfigurations."enkidu" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
# Overlays-module makes "pkgs.unstable" available in configuration.nix
({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-unstable ]; })
inputs.impermanence.nixosModules.impermanence
./systems/enkidu/configuration.nix
];
};
darwinConfigurations."adapa" = darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [
/*
nix-homebrew.darwinModules.nix-homebrew
{
nix-homebrew = {
enable = true;
user = "jsz";
taps = with inputs; {
"homebrew/homebrew-core" = homebrew-core;
"homebrew/homebrew-cask" = homebrew-cask;
};
mutableTaps = false;
};
}
*/
./systems/adapa/configuration.nix
];
};
homeConfigurations = {
"jsz@enkidu" = let system = "x86_64-linux"; in home-manager.lib.homeManagerConfiguration {
inherit (stuff.${system}) pkgs;
modules = [
./hm/conf/enkidu.nix
];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
};
"jsz@adapa" = let system = "x86_64-darwin"; in home-manager.lib.homeManagerConfiguration {
inherit (stuff.${system}) pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [ ./hm/conf/adapa.nix ];
};
};
};
} |
@jacekszymanski many thanks your first recommendation did work! I do not know, if this issue can be resolved or not cause @oneirocosm chimed in with another question. Thanks again. |
I got it working as well. Unfortunately, the casks I was looking for won't run with this setup for some reason even though they get downloaded. But I should probably check the homebrew versions to see if that's where the issue comes from. Thanks for the help! |
If some cask isn't working for whatever reason, feel free to post an issue with logs/error messages. I'm not saying that every cask is going to work with Nix (e.g. some apps require to be run from /Applications, or run installers and these most probably won't be supported), but some may be fixable, and after merging the overrides branch it will be possible to add/override specific steps for individual casks if that's what's needed. |
Hi,
first of all thank you for this project.
I am pretty new to nix and nixos.
I am using Home Manager, nix-darwin to manage my MacBook unfortunately there is some heavy lifting as you also encountered with homebrew in nix-darwin. Now I found your project and want to use it.
BUT, I do not know how to add
nixcasks = inputs.nixcasks.legacyPackages."${system}"
to pkgs.My configuration:
Thank you for your help!
Daniel
The text was updated successfully, but these errors were encountered: