Code Monkey home page Code Monkey logo

nix-starter-configs's Introduction

Nix Starter Config

This repo contains a few a simple nix flake templates for getting started with NixOS + home-manager.

What this provides

  • Minimal version:
    • NixOS configuration on nixos/configuration.nix, accessible via nixos-rebuild --flake .
    • Home-manager configuration on home-manager/home.nix, accessible via home-manager --flake .
  • Standard version:
    • Basic boilerplate for adding custom packages (under pkgs) and overlays (under overlay). Accessible on your system, home config, as well as nix build .#package-name.
    • Boilerplate for custom NixOS (modules/nixos) and home-manager (modules/home-manager) modules
    • NixOS and home-manager configurations from minimal, and they should also use your overlays and custom packages right out of the box.

Getting started

Assuming you have a basic NixOS booted up (either live or installed, anything works). Here's a link to the latest NixOS downloads, just for you.

Alternatively, you can totally use nix and home-manager on your existing distro (or even on Darwin). Install nix and follow along (just ignore the nixos-* commands).

What template to chose?

If this is your first trying flakes, or you're attempting to migrate your (simple) config to it; you should use the minimal version.

If you're here looking for inspiration/tips/good practices (and you already use flakes), or you're migrating a config that already has overlays and custom packages; try the standard version.

I like your funny words, magic man

Not sure what this all means?

Take a look at the learn hub on the NixOS website (scroll down to guides, the manuals, and the other awesome learning resources).

Learning the basics of what Nix (the package manager) is, how the Nix language works, and a bit of NixOS basics should get you up and running. Don't worry if it seems a little confusing at first. Get confortable with the basic concepts and come back here to get your feet wet, it's the best way to learn!

The repo

  • Install git, if you haven't already.
  • Create a repository for your config, for example:
cd ~/Documents
git init nix-config
cd nix-config
  • Make sure you're running Nix 2.4+, and opt into the experimental flakes and nix-command features:
# Should be 2.4+
nix --version
export NIX_CONFIG="experimental-features = nix-command flakes"
  • Get the template:
# For minimal version
nix flake init -t github:misterio77/nix-starter-config#minimal

# For standard version
nix flake init -t github:misterio77/nix-starter-config#standard
  • If you want to use NixOS: add stuff you currently have on /etc/nixos/ to nixos (usually configuration.nix and hardware-configuration.nix, when you're starting out).
    • The included file has some options you might want, specially if you don't have a configuration ready. Make sure you have generated your own hardware-configuration.nix; if not, just mount your partitions to /mnt and run: nixos-generate-config --root /mnt.
  • If you want to use home-manager: add your stuff from ~/.config/nixpkgs to home-manager (probably home.nix).
    • The included file is also a good starting point if you don't have a config yet.
  • Take a look at flake.nix, making sure to fill out anything marked with FIXME (required) or TODO (usually tips or optional stuff you might want)
  • Update your flake lock with nix flake update, so you get the latest packages and modules
  • git add and git push your changes! Or at least copy them somewhere if you're on a live medium.

Usage

  • Run sudo nixos-rebuild switch --flake .#hostname to apply your system configuration.
    • If you're still on a live installation medium, run nixos-install --flake .#hostname instead, and reboot.
  • Run home-manager switch --flake .#username@hostname to apply your home configuration.
    • If you don't have home-manager installed, try nix shell nixpkgs#home-manager.

And that's it, really! You're ready to have fun with your configurations using the latest and greatest nix3 flake-enabled command UX.

What next?

Use home-manager as a NixOS module

If you prefer to build your home configuration together with your NixOS one, it's pretty simple.

Simply remove the homeConfigurations block from the flake.nix file; then add this to your NixOS configuration (either directly on nixos/configuration.nix or on a separate file and import it):

{ inputs, outputs, ... }: {
  imports = [
    # Import home-manager's NixOS module
    inputs.home-manager.nixosModules.home-manager
  ];

  home-manager = {
    extraSpecialArgs = { inherit inputs outputs; };
    users = {
      # Import your home-manager configuration
      your-username = import ../home-manager/home.nix;
    };
  };
}

In this setup, the home-manager tool will not be installed (see nix-community/home-manager#4342). To rebuild your home configuration, use nixos-rebuild instead.

But if you want to install the home-manager tool anyways, you can add the package into your configuration:

# To install it for a specific user
users.users = {
  your-username = {
    packages = [ inputs.home-manager.packages.${pkgs.system}.default ];
  };
};

# To install it globally
environment.systemPackages =
  [ inputs.home-manager.packages.${pkgs.system}.default ];

Adding more hosts or users

You can organize them by hostname and username on nixos and home-manager directories, be sure to also add them to flake.nix.

You can take a look at my (beware, here be reproductible dragons) configuration repo for ideas.

NixOS makes it easy to share common configuration between hosts (you might want to create a common directory for these), while keeping everything in sync. home-manager can help you sync your environment (from editor to WM and everything in between) anywhere you use it. Have fun!

User password and secrets

You have basically two ways of setting up default passwords:

  • By default, you'll be prompted for a root password when installing with nixos-install. After you reboot, be sure to add a password to your own account and lock root using sudo passwd -l root.
  • Alternatively, you can specify initialPassword for your user. This will give your account a default password, be sure to change it after rebooting! If you do, you should pass --no-root-passwd to nixos-install, to skip setting a password on the root account.

If you don't want to set your password imperatively, you can also use passwordFile for safely and declaratively setting a password from a file outside the nix store.

There's also more advanced options for secret management, including some that can include them (encrypted) into your config repo and/or nix store, be sure to check them out if you're interested.

Dotfile management with home-manager

Besides just adding packages to your environment, home-manager can also manage your dotfiles. I strongly recommend you do, it's awesome!

For full nix goodness, check out the home-manager options with man home-configuration.nix. Using them, you'll be able to fully configure any program with nix syntax and its powerful abstractions.

Alternatively, if you're still not ready to rewrite all your configs to nix syntax, there's home-manager options (such as xdg.configFile) for including files from your config repository into your usual dot directories. Add your existing dotfiles to this repo and try it out!

Try opt-in persistance

You might have noticed that there's impurity in your NixOS system, in the form of configuration files and other cruft your system generates when running. What if you change them in a whim to get something working and forget about it? Boom, your system is not fully reproductible anymore.

You can instead fully delete your / and /home on every boot! Nix is okay with a empty root on boot (all you need is /boot and /nix), and will happily reapply your configurations.

There's two main approaches to this: mount a tmpfs (RAM disk) to /, or (using a filesystem such as btrfs or zfs) mount a blank snapshot and reset it on boot.

For stuff that can't be managed through nix (such as games downloaded from steam, or logs), use impermanence for mounting stuff you to keep to a separate partition/volume (such as /nix/persist or /persist). This makes everything vanish by default, and you can keep track of what you specifically asked to be kept.

Here's some awesome blog posts about it:

Note that for home-manager to work correctly here, you need to set up its NixOS module, as described in the previous section.

Adding custom packages

Something you want to use that's not in nixpkgs yet? You can easily build and iterate on a derivation (package) from this very repository.

Create a folder with the desired name inside pkgs, and add a default.nix file containing a derivation. Be sure to also callPackage them on pkgs/default.nix.

You'll be able to refer to that package from anywhere on your home-manager/nixos configurations, build them with nix build .#package-name, or bring them into your shell with nix shell .#package-name.

See the manual for some tips on how to package stuff.

Adding overlays

Found some outdated package on nixpkgs you need the latest version of? Perhaps you want to apply a patch to fix a behaviour you don't like? Nix makes it easy and manageble with overlays!

Use the overlays/default.nix file for this.

If you're creating patches, you can keep them on the overlays folder as well.

See the wiki article to see how it all works.

Adding your own modules

Got some configurations you want to create an abstraction of? Modules are the answer. These awesome files can expose options and implement configurations based on how the options are set.

Create a file for them on either modules/nixos or modules/home-manager. Be sure to also add them to the listing at modules/nixos/default.nix or modules/home-manager/default.nix.

See the wiki article to learn more about them.

Troubleshooting / FAQ

Please let me know any questions or issues you face with these templates, so I can add more info here!

Nix says my repo files don't exist, even though they do!

Nix flakes only see files that git is currently tracked, so just git add . and you should be good to go. Files on .gitignore, of course, are invisible to nix - this is to guarantee your build won't depend on anything that is not on your repo.

Nix installs the wrong version of software/fails to find new software

The nix dependencies (such as nixpkgs) used by your configuration will strictly follow the flake.lock file, using the commits written into it when you (re)generated.

To update your flake inputs, simply use nix flake update.

nix-starter-configs's People

Contributors

ajgrf avatar dmytrokyrychuk avatar gabyx avatar gerg-l avatar jmanch avatar juangiordana avatar latenighticecream avatar misterio77 avatar musjj avatar yannipapandreou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nix-starter-configs's Issues

currentSystem missing

Hi, im using the minimal version and currently just started using nixos, but im having error after doing sudo nixos-rebuild switch --flake .#art

here is the error

warning: Git tree '/home/hoaxdream/.config/nixosdots' is dirty
error: attribute 'currentSystem' missing
          at /nix/store/6v8l94l7zssb6l87azm0gcz9bjwa8lhw-source/nixos/lib/eval-config.nix:13:12:
          
          12| { # !!! system can be set modularly, would be nice to remove
          13|   system ? builtins.currentSystem
                                 ^
          14| , # !!! is this argument needed any more? The pkgs argument can

Question about how imports work with home-manager for this setup

Hello Gabriel,
Thanks again for this repo. I'm running NixOS now thanks to you.

I've run into a little problem while configuring Helix for language servers, etc. I created a "programs" directory in the "home-manager" directory with a default.nix file in it, and then a helix sub-directory, and then added imports = [ ./programs ]; to the home.nix file. I then went too far for my level of understanding, and tried also adding your nix-colors package through the flake.nix file, and also referencing it in the imports of the home.nix file. I got an error stating, ./programs does not look like a module. I then removed the reference to nix-colors, modified the import statement to: imports = import ./programs; which works fine, but now I don't have nix-colors, of course.

My question is whether I am doing this all wrong for the architecture you've set up. Should I be putting my helix config and theme files in "modules/home-manager"? And if I do that what would the include look like in the home.nix file? Does it magically recognize modules, or would I need to reference a path?

I know you're busy so no rush, no hard feelings if you don't have time...
All the best,
Leigh

Newbie clarification in when using 'nixos-install --flake .#hostname'

Hi,

Thank you so much for making this, I am learning more about nixos here than anywhere else.

I am however a dumbass and get stuck on simple things.

When i read the command below from the Readme, I assumed that the hash was to be removed as it was similar to a comment. An hour later I realized it was required (RTFM, I know)
nixos-install --flake .#hostname

Could a little note be added to keep the hash, so others don't get tripped up? It's an eclectic way to adding arguments to a program and looks 'wrong' on first glance.
If this is a non issue, please feel free to close this.

Thanks again

Let's get configurations and home-manager working with stable and unstable

Hi again,

Now that 22.11 is stable, I have tried to update my nix flakes to 22.11, and I synchronized my config files to the most recent version of this repo. This went without much hassle, but now again I am trying to add nix-unstable to the mix and am failing somewhere, because my changes seem to work, but for some reason the allowUnfree does not get accepted.

What I did so far was as follows. First, my flake.nix file contains this:

 inputs = {
    # Nixpkgs
    hardware.url = "github:nixos/nixos-hardware";
    nixpkgs.url  = "github:nixos/nixpkgs/nixos-22.11";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";

    # Home manager
    home-manager.url = "github:nix-community/home-manager/release-22.11";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };

outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, ... }@inputs:

in extraSpecialArgs under my username, well, let me just post the entire stanza:

        "mark@myhost" = home-manager.lib.homeManagerConfiguration {
          pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
          extraSpecialArgs = {
            inherit inputs outputs overlays;
            pkgs-unstable = nixpkgs-unstable.legacyPackages.x86_64-linux;
          };
          modules = [
            ./home-manager/myhost-mark.nix
          ];
        };

And finally in my home-manager/myhost-mark.nix, first:

{ inputs, outputs, lib, config, pkgs, pkgs-unstable, ... }: {

and then under home.packages = with pkgs; [
pkgs-unstable.vivaldi

Here's the problem: error: Package ‘vivaldi-5.6.2867.36’ in /nix/store/v3h6hhxf4f5l5ix3p70jap046zl2plm1-source/pkgs/applications/networking/browsers/vivaldi/default.nix:102 has an unfree license (‘unfree’), refusing to evaluate.

In other words: the allowUnfree is apparently not read for nixpkgs-unstable.

I got so close! But one issue is remaining: no matter what I try to do - add allowUnfree = true to nixpkgs.nix, or to home-manager/myhost-mark.nix, or add allowUnfreePredicate = (_: true); to home-manager/myhost-mark.nix... vivaldi-unstable will not install and keeps giving me this error. Please advise what to do 😅

Thank youuu <3
Mark

Please dokument on how to add a custom package to configurattion.nix

I successfully created a package simpleScript which I can run via nix run .#simpleScript`

But when I try to add it to my configuration.nix it fails:

 sudo nixos-rebuild dry-build --flake .#your-hostname
building the system configuration...
warning: Git tree '/opt/src/nix-starter-config' is dirty
error: attribute 'simpleScript' missing

       at /nix/store/1lm85rfzigx86v60yy3fab9qjddlqq2y-source/standard/nixos/configuration.nix:61:43:

           60|   };
           61|   environment.systemPackages = [ pkgs.vim pkgs.simpleScript ];
             |                                           ^
           62|   # FIXME: Add the rest of your current configuration
(use '--show-trace' to show detailed location information)

Patch for this example is attached.

example.ZIP

Adding a function to iterate over files in git repository?

Hi! Thank you for this excellent resource.

This is more of a would-you-be-interested-in-this-addition type of question, rather than an issue.

I did not directly want to embed the configuration of all of my dotfiles file in home-manager, and wanted to include every file in my existing git repo when switching to the new config, without hassle. So I've wrote a function that made migrating to home-manager easier by mapping the files from an existing git-repo containing dotfiles to the required home-manager attributes.

I've included the code below.

home.nix

let
  pkgsUnstable = import <nixpkgs-unstable>{};

  ....

  username = "pimvh";

  homeDirectory = "/home/${username}";

  dotFiles = import ./dotfiles.nix {
    lib = lib;
    homeDirectory = homeDirectory;
  };

  ...

in {
  # Home Manager needs a bit of information about you and the paths it should
  # manage.
  home.username      = username;
  home.homeDirectory = homeDirectory;
  
  home.file = dotFiles.all.home;
  xdg.configFile = dotFiles.all.xdgConfig;

./dotfiles.nix

# use the relative path in dotfiles GitHub repository (./dotfiles, submodule from home-manager repo)
# to put files in the correct place.
{ lib, homeDirectory, ... }:
let
  generateDotFilesPaths = rootPath: (
    let
      fileList = lib.filesystem.listFilesRecursive rootPath;

      #  filter the files which contain `.git` after removing the prefix of the fileList
      relativePaths = builtins.filter (x: ! lib.hasInfix ".git" x) (map (x: lib.removePrefix rootPath x) fileList);

      # build a function that to generate the required structure.
      generateFileAttrs = val: {
        "${val}".source = "${rootPath}/${val}";
      };

      # map the list of files into that structure.
      # differentiate home files (anything in ~), and files stored under .config
      homeFilesList      = builtins.filter (x: !lib.hasInfix ".config" x) relativePaths;
      xdgConfigFilesList = builtins.filter (x:  lib.hasInfix ".config" x) relativePaths;

      # merge the elements of the list into a single map
      homeFiles        = lib.attrsets.mergeAttrsList (map generateFileAttrs homeFilesList);
      xdgConfigFiles   = lib.attrsets.mergeAttrsList (map generateFileAttrs xdgConfigFilesList);
    in
      {
        home      = homeFiles;
        xdgConfig = xdgConfigFiles;
      }
  );

in {
  # make a function that takes in a path to the root
  # string -> attrset[string : attrset]
  all = generateDotFilesPaths "${homeDirectory}/.config/home-manager/dotfiles";
}

As your repository already has good exposure I think it would help others out. Let me know if you would like me to contribute it.

Readme "Use home-manager as a NixOS module" section encoutered some issues on my system

I'm on a nixos 22.11 system and converted over to nix-start-configs today - thank you, this is great so far!

I ran into some problems with the "Use home-manager as a NixOS module" section:
The "import ../home-manager" was looking for home-manager/default.nix but the nix file is home.nix. So, I changed that line to:
import ../home-manager/home.nix.

It was failing to compile because the home.nix 'outputs' wasn't defined.
I fixed this by:
Adding 'outputs' to my nixos/configuration.nix parameters
Adding 'outputs' to the extraSpecialArgs for homeManager in configuration.nix

After this it worked great!

Am I doing something wrong here? Or are these actual issues with the README? If so, happy to put up a PR.

[Question] Differences between forAllSystems and forEachSystem

Sorry for asking nooby stupid question.
In this config,

forAllSystems = nixpkgs.lib.genAttrs systems;

in flake.nix.
However, in your own config, you did

forEachSystem = f: lib.genAttrs systems (system: f pkgsFor.${system});
pkgsFor = lib.genAttrs systems (system: import nixpkgs {
        inherit system;
        config.allowUnfree = true;
});

in flake.nix.
I tried to understand but I could not figure it out and both works on my x86_64-linux system.

system.copySystemConfiguration is not supported with flakes

First of all, thank you for sharing this with the community, especially a total NixOS beginner like me.

I'm running nix (Nix) 2.13.3, Stable. I believe I followed the instructions pertaining to the Minimal version, but obtained a Failed assertions error, as shown below. You'll note that I modified the various, required files to include my personal info (as stated in the instructions). I must have done something wrong, however. Also note that I did not have Home Manager enabled prior to following these instructions (don't know if that plays a role in the error). Can you please help?

nix-config on  master [+] 
❯ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
	new file:   flake.lock
	new file:   flake.nix
	new file:   home-manager/home.nix
	new file:   nixos/configuration.nix
	new file:   nixos/hardware-configuration.nix


nix-config on  master [+] 
❯ sudo nixos-rebuild switch --flake .#fastnix
warning: Git tree '/home/r0b0ty/Projects/nix-config' is dirty
building the system configuration...
warning: Git tree '/home/r0b0ty/Projects/nix-config' is dirty
error:
       Failed assertions:
       - system.copySystemConfiguration is not supported with flakes
(use '--show-trace' to show detailed location information)

Multiple inputs, unsure if used

Hey, greetings! Thanks for these configs and your repo at https://github.com/Misterio77/nix-config

It's helped me get a bit better with using nix+flakes to manage my systems.

One issue I'm seeing is that I have a few inputs I'm unclear if I'm using properly (emacs-overlay mainly) and I'm curious about the updates that show several inputs being updated, as in this example::

What methods do you use to debug inputs/outputs to ensure they're in use, etc. I don't expect you to be able to review my dotfiles much but was curious if you knew of any common mistakes people make, perhaps that I've made.

feel free to close if you have no time to answer and thanks again for this repo.

THANK YOU

This is exactly what I needed to push through a problem I was facing. Thanks for sharing this.

Feel free to close, sorry for the extra noise.

Example of adding a local package to be recognised by home-manager build is missing

I was following this nice starter config and was especially interested in the ability to define local packages under pkgs/. However I can't get home-manager build succeed because it always complains about my local package being unknown.

Example:

I have my package defined under:

├── pkgs
│   ├── mypkg
│   │   └── default.nix
│   └── default.nix

with all the other configuration taken from the standard example simply adding
home.packages = with pkgs; [ mypkg ]; as suggested in

# home.packages = with pkgs; [ steam ];

is not enough since home-manger build will complain with
error: undefined variable 'mypkg'

Doing a nix build .#mypkg works fine though.

So how should one add the mypkg in order that it will be found by home-manager build?

Home manager does not install or build with config (reproducer included)

My understanding is that this config is using home-manager as a nixos module. So whenever you do nixos-rebuild switch or nixos-rebuild vm the home-manage configuration should ge run too.

That doesn't happen though, and you can reproduce locally with:

git clone https://github.com/ParetoOptimalDev/try-nix-starter-config
cd try-nix-starter-config
git checkout a7d38df74b1d46631e7026f9a76ff23e5fbd7588
nixos-rebuild build-vm --flake .#your-hostname
/result/bin/run-your-hostname-vm 
# you can login with username and password nixos

related to #12. After reading #12 I thought "Oh... maybe the home-manager binary is available even though the home-manager nixos module wasn't run".

However home-manager in the shell after logging in returns home-manager: command not found.

Configurate Home Manager to Allow Unfree Packages

Hello! I've been struggling to get a Flake + Home Manager nixos install working on my computer, and your starter configs are really helping me out., so thank you.

I've just got one thing hanging me up. When I run home-manager with my home.nix file, it won't install chrome, and complains that I need to allow unfree packages. Could you tell me where, in your schema, I can add a snippet like config = allowUnfree to get Home-Manager to install chrome?

All the best,
Leigh GABLE

Question about `pkgs` attribute

I'm slightly confused about the handling of nixpkgs in flake configs.

The flake introduced an input for nixpkgs:

inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";

And we override the system's registery with:

nix = {
# This will add each flake input as a registry
# To make nix3 commands consistent with your flake
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
# This will additionally add your inputs to the system's legacy channels
# Making legacy nix commands consistent as well, awesome!
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;

Does that mean that the pkgs attribute that a module receives is now using the new nixpkgs introduced in our flake? Or am I misunderstanding something here.

your-username@your-hostname

Hi Misterio77,

I am learning a great deal with your starter configs. Thank you :)

There is one thing though I struggle to make sense of when using the standalone version of home-manager:

I wonder what is the benefit from using:
homeConfigurations = { "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration {

Intead of :
homeConfigurations = { user-name = home-manager.lib.homeManagerConfiguration {

Is there actually a difference? Maybe it just come down to preference or good practice.
To my newbie eyes the "your-username@your-hostname" seems redundant, for instance if you have two hosts and the same user. It also prevents you from using the simple home-manager switch --flake . shortcut when switching to a new home manager generation.
Or maybe it's a way to tweak your user setting per host.

PS: learning github as well, I do not have all the codes yet.

flake-newbie - question

Hi,
i just started with nixos and flakes especially. I just setup a test system and applied your config. Once in a minimal config and a standard config.
The Things i wonder - where i'm wrong - is

  • Home-Manager seems in both version not to be installed or applied. Do i need to add it as as a software anywhere? or what am i using wrong?
  • Just i wanted to add https://github.com/nagisa/nixpkg-openhab as a module - so i added the config example as module and refered to it as input module modules/nixos
    openhab = import ./openhab.nix;
    and the example from openhab
    # ...;
    openhab.url = "github:nagisa/nixpkg-openhab";
    openhab.inputs = {
        # In case you alrady depend on `nixpkgs` in your flake, consider having `openhab`
        # “follow” it:
        nixpkgs.follows = "nixpkgs";
        # Similarly, for flake-utils:
        flake-utils.follows = "flake-utils";
    };
};

I'm under the impression that nothing at all where done with it. But thats maybe an issue with my missing understanding of the whole concept.

Just thanks for adding the work and the patience with the beginners here.
Johannes

How to add an overlay?

First, thanks for this template. I've almost been able to convert my configuration to flakes.
The only thing I'm missing is overlays. I thought just adding them in the overlay folder would be enough, but it looks like it doesn't work?

How to add overlays such as emacs-overlay to primary nixpkgs

This is partially covered in #48, however that's for if you want to add to the unstable-packages overlay.

I've instead:

  • switched my primary nixpkgs to unstable
  • created a stable overlay

I added it to my inputs:

      emacs-overlay.url  = "github:nix-community/emacs-overlay";

This makes available pkgs.inputs.emacs-overlay.emacs-pgtk for example, which partially works.

However for some reason, it doesn't seem to also include pkgs.inputs.emacs-overlay.emacsWithPackagesFromUsePackage for some reason.

Maybe this is some sort of merging error?

Also, if I wanted to include the override so that I could just use pkgs.emacs-pgtk throughout my configuration, how would I do that in this config?

Thanks!

Can't use custom package in module?

Hi, Thanks so much for providing this to get started with nix.
I've started with the standard template. I'm trying to copy your shellcolord package and module into my configuration and am having trouble. Here's the error:

cole@pulsar:~/nixfiles/ > home-manager switch --flake .#cole@pulsar                         
error: attribute 'shellcolord' missing

       at /nix/store/4mvzvcj6l01jc51j800hjvhxx02q3afr-source/modules/home-manager/shellcolor.nix:5:13:

            4|   cfg = config.programs.shellcolor;
            5|   package = pkgs.shellcolord;
             |             ^
            6|

As far as I can tell, everything looks correct but I'm new and I might be missing something. Here's my config: https://github.com/thecatwasnot/nixfiles/tree/shellcolor

home-manager both standalone and NixOS module at the same time?

Hi,

first of all, thanks a lot. Editing smth in nix and writing from scratch are two very different things for someone who is not really familiar with nix programming language and its libs[docs suck as well :( ]. Having such template helps so much.

Let me first give the context for my question.

  • home/test.nix contains my home-manager config for user test
  • there is homeConfiguration which includes home/test.nix as a module
  • there is nixosConfiguraion which includes home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.test = import ./home/test.nix;} as a module.

Now, deploying both nixosConfiguration with nixos-rebuild and homeConfiguration with home-manager should produce same environment for the user, since it's the same home/test.nix.

What I want:

  • to be able to easily change configuration using home-manager command without rebuilding whole system(add new packages, configure them, commit home/test.nix)
  • at the same time, every time my system is being updated using nixos-rebuild, I want user environment to be updated as well

Right now if I deploy using nixos-rebuild , there's no home-manager command available for the user, despite having programs.home-manager.enable = true; in home/test.nix, which puzzles me quite a bit.

I did read in #12 that I can create a generation of home-manager and activate it manually, but as I understand next nixos configuration being built will create new generation of home-manager configuration without home-manager command available again. Also would be nice to avoid doing it manually. This is what programs.home-manager.enable = true; should be for, in my understanding.

Could you please advice how can I achieve what I want?

Rebuilding with custom packages fails

I wrote a simple shell script using writeShellApplication in a file called default.nix, inside a folder called custompackage in the pkgs folder, and then added it to pkgs/default.nix like this:
custompackage = pkgs.callPackage ./custompackage {};

After that, I tried adding it to environment.systemPackages or home.packages, but either way, rebuilding fails with:
attribute 'callPackage' missing

I'm using the standard template, and it does build if pkgs/default.nix has no package.

[Standard] "error: attribute 'outputs' missing"

Hi there! I found this template while looking through GitHub, and since I'm genuinely urging to try out NixOS, I thought I'd give this one a go.

I slightly modified the standard config and gave it a run… and I got an error. The error is mentioned in the title — error: attribute 'outputs' missing was on the screen. Here's the full error seen when running nix flake check:

[zyx@apollyon:~/.zetup]$ nix flake check

warning: unknown flake output 'homeManagerModules'
error: attribute 'outputs' missing

       at /nix/store/4bdz2j6lry2vl44bcdaaarcap1p7qfpb-source/lib/modules.nix:483:28:

          482|         builtins.addErrorContext (context name)
          483|           (args.${name} or config._module.args.${name})
             |                            ^
          484|         ) (lib.functionArgs f);

Here is a SourceBin paste of my flake.nix: https://srcb.in/BubS6kb87l

I'm still learning NixOS, so this is something I am almost completely unfamiliar with. All help is appreciated!

Home Manager Not Installed

Hello! I'm a recent NixOS explorer attempting to convert a very basic configuration into the minimal flake, but I'm unable to run home manager after rebuilding. Rebuilding from the flake is going just fine, but when I attempt to use the home manager syncing command, it tells me that home manager is not installed. I'll post what I've done that I believe may be pertinent.

path:/home/jeff/nix-flake?lastModified=1669694425&narHash=sha256-Ig67V1wT9ko76L5AU76HDqEmT9wFlFwqv71bCDb4Uc4=
├───homeConfigurations: unknown
└───nixosConfigurations
    └───leggero: NixOS configuration
{
  description = "Your new nix config";

  inputs = {
    # Nixpkgs
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

    # Home manager
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";

    # TODO: Add any other flake you might need
    hardware.url = "github:nixos/nixos-hardware";

    # Shameless plug: looking for a way to nixify your themes and make
    # everything match nicely? Try nix-colors!
    # nix-colors.url = "github:misterio77/nix-colors";
  };

  outputs = { nixpkgs, home-manager, ... }@inputs: {
    nixosConfigurations = {
      # FIXME replace with your hostname
      leggero = nixpkgs.lib.nixosSystem {
        specialArgs = { inherit inputs; }; # Pass flake inputs to our config
        # > Our main nixos configuration file <
        modules = [ ./nixos/configuration.nix ];
      };
    };

    homeConfigurations = {
      # FIXME replace with your username@hostname
      "jeff@leggero" = home-manager.lib.homeManagerConfiguration {
        pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
        extraSpecialArgs = { inherit inputs; }; # Pass flake inputs to our config
        # > Our main home-manager configuration file <
        modules = [ ./home-manager/home.nix ];
      };
    };
  };
}

And in home.nix

home = {
  username = "jeff";
  homeDirectory = "/home/jeff";
};

I'm likely doing something very basic that I just haven't figured out how to fix yet, but I'd love some help!

How to update `nix` to v2.4+?

The README says to be using nix version 2.4, but I am on 2.13.3

Make sure you're running Nix 2.4+, and opt into the experimental flakes and nix-command features:

# Should be 2.4+
nix --version
export NIX_CONFIG="experimental-features = nix-command flakes"

How do I upgrade this? Does it matter? I added nix.settings.experimental-features = [ "nix-command" "flakes" ]; to my configuration.nix and ran sudo nixos-rebuild switch --upgrade-all, but my system still returns v2.13.3 (from nix --version)

I know this probably isn't the right place but I couldn't find any information about it online

Using NixOs v23.05, blank install from GUI ISO

Docs for use in WSL?

Hi, I've used your starter configs several times, they're quite helpful and well thought out. Thank you.

I'm trying to use them with https://github.com/nix-community/NixOS-WSL and running into issues. Here's my work in progress. ("nixos@nixos" is the WSL entry)

I've kept some notes on those issues, you can see them below.

It's possible that these errors are consequences of a bad choice I've made. I don't necessarily need fixes or workarounds. Perhaps a bit of guidance to set me on the right path would allow me to sidestep these issues entirely.

This issue is a request that you take a look at https://github.com/nix-community/NixOS-WSL and document any special considerations that one would make when adding such an environment to their flake.nix.


Firstly:

$ sudo nixos-rebuild switch --flake .#wsl
warning: Git tree '/home/nixos/src/home4' is dirty
error: cannot look up '<nixos-wsl/modules>' in pure evaluation mode (use '--impure' to override)

       at /nix/store/h1sgmkvhfia1wjc224j2822zjkxrncrh-source/wsl/configuration.nix:13:5:

           12|     # include NixOS-WSL modules
           13|     <nixos-wsl/modules>
             |     ^
           14|   ];
(use '--show-trace' to show detailed location information)

Ok so I've added --impure. Next:

[nix-shell:~/src/home4]$ sudo nixos-rebuild switch --flake .#wsl --impure
warning: Git tree '/home/nixos/src/home4' is dirty
building the system configuration...
warning: Git tree '/home/nixos/src/home4' is dirty
error: A definition for option `fileSystems."/mnt/wslg/distro".device' is not of type `null or string (with check: non-empty)'. Definition values:
       - In `/nix/store/nlv99p2ipr7lbbrg38lz9dcizydjcavm-source/wsl/hardware-configuration.nix': ""
(use '--show-trace' to show detailed location information)

Ok, I removed all references to wslg from hardware-configuration.nix, I don't think I care about whatever it is. Next:

$ home-manager switch --flake .#nixos@nixos --show-trace
warning: Git tree '/home/nixos/src/home4' is dirty
error:
       … from call site

         at /nix/store/m5wxwjc2axqsywb1w5l8sqi5kx3pqr5s-source/modules/default.nix:39:12:

           38|
           39|   module = showWarnings (
             |            ^
           40|     let

       … while calling 'showWarnings'

         at /nix/store/m5wxwjc2axqsywb1w5l8sqi5kx3pqr5s-source/modules/default.nix:18:18:

           17|
           18|   showWarnings = res:
             |                  ^
           19|     let

       … from call site

         at /nix/store/m5wxwjc2axqsywb1w5l8sqi5kx3pqr5s-source/modules/default.nix:22:7:

           21|     in
           22|       fold f res res.config.warnings;
             |       ^
           23|

       … while calling 'foldr'

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/lists.nix:53:20:

           52|   */
           53|   foldr = op: nul: list:
             |                    ^
           54|     let

       … from call site

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/lists.nix:60:8:

           59|         else op (elemAt list n) (fold' (n + 1));
           60|     in fold' 0;
             |        ^
           61|

       … while calling 'fold''

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/lists.nix:56:15:

           55|       len = length list;
           56|       fold' = n:
             |               ^
           57|         if n == len

       … from call site

         at /nix/store/m5wxwjc2axqsywb1w5l8sqi5kx3pqr5s-source/modules/default.nix:41:16:

           40|     let
           41|       failed = collectFailed rawModule.config;
             |                ^
           42|       failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);

       … while calling 'collectFailed'

         at /nix/store/m5wxwjc2axqsywb1w5l8sqi5kx3pqr5s-source/modules/default.nix:15:19:

           14|
           15|   collectFailed = cfg:
             |                   ^
           16|     map (x: x.message) (filter (x: !x.assertion) cfg.assertions);

       … from call site

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:242:28:

          241|           # For definitions that have an associated option
          242|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                            ^
          243|

       … while calling 'mapAttrsRecursiveCond'

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/attrsets.nix:594:5:

          593|     # Attribute set to recursively map over.
          594|     set:
             |     ^
          595|     let

       … from call site

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:234:33:

          233|           ({ inherit lib options config specialArgs; } // specialArgs);
          234|         in mergeModules prefix (reverseList collected);
             |                                 ^
          235|

       … while calling 'reverseList'

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/lists.nix:510:17:

          509|   */
          510|   reverseList = xs:
             |                 ^
          511|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;

       … from call site

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:229:25:

          228|       merged =
          229|         let collected = collectModules
             |                         ^
          230|           class

       … while calling anonymous lambda

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:443:37:

          442|
          443|     in modulesPath: initialModules: args:
             |                                     ^
          444|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);

       … from call site

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:444:7:

          443|     in modulesPath: initialModules: args:
          444|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
             |       ^
          445|

       … while calling 'filterModules'

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:411:36:

          410|       # modules recursively. It returns the final list of unique-by-key modules
          411|       filterModules = modulesPath: { disabled, modules }:
             |                                    ^
          412|         let

       … while calling anonymous lambda

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:437:31:

          436|           disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
          437|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
             |                               ^
          438|         in map (attrs: attrs.module) (builtins.genericClosure {

       … from call site

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:398:22:

          397|           let
          398|             module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
             |                      ^
          399|             collectedImports = collectStructuredModules module._file module.key module.imports args;

       … while calling anonymous lambda

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:363:11:

          362|         else
          363|           m: m;
             |           ^
          364|

       … from call site

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:398:35:

          397|           let
          398|             module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
             |                                   ^
          399|             collectedImports = collectStructuredModules module._file module.key module.imports args;

       … while calling 'loadModule'

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:334:53:

          333|       # Like unifyModuleSyntax, but also imports paths and calls functions if necessary
          334|       loadModule = args: fallbackFile: fallbackKey: m:
             |                                                     ^
          335|         if isFunction m then

       … from call site

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:352:14:

          351|           throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
          352|         else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
             |              ^
          353|

       … while calling 'unifyModuleSyntax'

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:452:34:

          451|      of ‘options’, ‘config’ and ‘imports’ attributes. */
          452|   unifyModuleSyntax = file: key: m:
             |                                  ^
          453|     let

       … from call site

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:352:59:

          351|           throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
          352|         else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
             |                                                           ^
          353|

       … while calling 'applyModuleArgsIfFunction'

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:486:39:

          485|
          486|   applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }:
             |                                       ^
          487|     if isFunction f then applyModuleArgs key f args else f;

       … from call site

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/modules.nix:487:8:

          486|   applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }:
          487|     if isFunction f then applyModuleArgs key f args else f;
             |        ^
          488|

       … while calling 'isFunction'

         at /nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source/lib/trivial.nix:448:16:

          447|   */
          448|   isFunction = f: builtins.isFunction f ||
             |                ^
          449|     (f ? __functor && isFunction (f.__functor f));

       error: getting status of '/nix/store/6pcrw7cayll73mvswvd4p0ij1257q63p-source/home': No such file or directory

And that's where I'm stuck

Home-manager with a package from unstable

Dear Misterio,

How do I install a package from unstable, in a home.nix file? Just one package, I prefer to keep the others at 22.05.

Previously I did it like this:

{ inputs, lib, config, pkgs, ... }:
let
  unstable = import <nixpkgs-unstable> { config = { allowUnfree = true; }; };
in
{
(...)

But this is considered impure in the world of flakes.

Sorry for my n00b question.

Mark

Exactly one of users.users..isSystemUser and users.users..isNormalUser must be set.

Hi. Newbie here, I have been using NixOS using non-flake setup for months. I decided to give flake a try and I found several starter configs including yours.

I have this issue with minimal version config, I was able to get home-manager working. However, I cannot get nixos to work as I kept getting this error. I'm not sure what went wrong so I wonder if it's due to your tinkering around and/or commented out user config.

❯ sudo nixos-rebuild switch --flake .#rog 
warning: Git tree '/home/chris/.nixpkgs' is dirty
building the system configuration...
warning: Git tree '/home/chris/.nixpkgs' is dirty
error:
       Failed assertions:
       - Exactly one of users.users..isSystemUser and users.users..isNormalUser must be set.

       - users.users..group is unset. This used to default to
       nogroup, but this is unsafe. For example you can create a group
       for this user with:
       users.users..group = "";
       users.groups. = {};
(use '--show-trace' to show detailed location information)

I have let user = "chris" and ${user} in my /etc/nixos/configuration for users/groups, but changing it to chris still produced this error with invisible user name in the message. I can't tell if I made a mistake.

Unrelated:

  • In nixos-hardware, common-ssd does not exists, but common-pc-ssd does. I used this one.
  • I also look forward to multiple users/hosts/machines issue too because I have aarch64 (darwin).

Can not access overlays in home-manager

Hello and thank you for great helping repo! It exactly what i am looking for.

In yours home.nix i have found these lines:

nixpkgs = {
    # You can add overlays here
    overlays = [
      # Add overlays your own flake exports (from overlays and pkgs dir):
      outputs.overlays.additions
      outputs.overlays.modifications
      outputs.overlays.unstable-packages
..........

In my flake i can not access overlays even when i send it via extraSpecialArgs.

I got these error message:


warning: Git tree '/home/serg/flake' is dirty
error: attribute 'overlays' missing

       at /nix/store/cw6dri0lvimqnrpq4gq80ayh609xay03-source/home-manager/home.nix:19:28:

           18|
           19|   nixpkgs = { overlays = [ outputs.overlays.unstable-packages]; };
             |                            ^
           20|
(use '--show-trace' to show detailed location information)

Here my flake.nix

{
  description = "My test of nix flake";

  inputs = {
    nixpkgs = {
      type = "github";
      owner = "NixOS";
      repo = "nixpkgs";
      ref = "nixpkgs-unstable";
    };

    nixpkgs-stable = {
      type = "github";
      owner = "NixOS";
      repo = "nixpkgs";
      ref = "release-22.11";
    };

    home-manager = {
      type = "github";
      owner = "nix-community";
      repo = "home-manager";
      ref = "master";
      inputs = { nixpkgs.follows = "nixpkgs-stable"; };
    };

    arkenfox-nixos = {
      type = "github";
      owner = "dwarfmaster";
      repo = "arkenfox-nixos";
      ref = "main";
      inputs = { nixpkgs.follows = "nixpkgs-stable"; };
    };
  };

  outputs = { self, nixpkgs, nixpkgs-stable, home-manager, arkenfox-nixos, ... }@inputs:
    let
      inherit (self) outputs;
      system = "x86_64-linux";
      overlays = import ./overlays { inherit inputs; };
      nixosModules.common = import ./modules/common;
    in with nixosModules; {
      #formatter.${system} = nixpkgs-stable.legacyPackages.${system}.nixfmt;
      nixosConfigurations.nixos = nixpkgs-stable.lib.nixosSystem {
        inherit system;
        modules = [
          common
          ./configuration.nix
        ];
      };
      homeConfigurations.serg = home-manager.lib.homeManagerConfiguration {
        pkgs = nixpkgs-stable.legacyPackages.${system};
        extraSpecialArgs = { inherit inputs outputs; };
        modules = [
          common
          ./home-manager/home.nix
          arkenfox-nixos.hmModules.arkenfox
        ];
      };
    };
}

Here my home.nix



{ outputs, config, lib, pkgs, ... }:

{
  # Home Manager needs a bit of information about you and the paths it should
  # manage.
  home.username = "serg";
  home.homeDirectory = "/home/serg";

  imports = [ ./programs ];

  home.stateVersion = "22.11"; # Please read the comment before changing.

  nixpkgs = { overlays = [ outputs.overlays.unstable-packages]; };

  home.packages = with pkgs; [
    radeontop
    tor-browser-bundle-bin
    rpcs3
    pcsx2
    qbittorrent
    gimp
    geeqie
    mkvtoolnix
    flacon
    mediainfo-gui
    picard
    keepassxc
    quodlibet-full
    unstable.telegram-desktop
    unstable.nicotine-plus
  ];

  home.file = {
    # # Building this configuration will create a copy of 'dotfiles/screenrc' in
    # # the Nix store. Activating the configuration will then make '~/.screenrc' a
    # # symlink to the Nix store copy.
    # ".screenrc".source = dotfiles/screenrc;

    # # You can also set the file content immediately.
    # ".gradle/gradle.properties".text = ''
    #   org.gradle.console=verbose
    #   org.gradle.daemon.idletimeout=3600000
    # '';
  };
  home.sessionVariables = {
    # EDITOR = "emacs";
  };

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
}

Overlays default.nix

{ inputs, ... }:

{
  unstable-packages = final: _prev: {
    unstable = import inputs.nixpkgs {
      system = final.system;
    };
  };
}

When i replace outputs to overlays in flake.nix

extraSpecialArgs = { inherit inputs overlays; };

and add "overlays" variable to home.nix via

{ , overlays, config, lib, pkgs, ... }: ...........
and do something like these
nixpkgs = { overlays = [ overlays.unstable-packages]; };

It seems works. Can you tell me what i am doing wrong, please?

ERROR when installing the standard config

Hi, first and foremost I am really new to Nix and NixOS, the last year I spent on Arch and it is really different, I was hoping to install the standard config of this started config so I followed the appropriate steps:

  1. I have this in my /etc/nixos/configuration.nix "nix.settings.experimental-features = [ "nix-command" "flakes" ];"
  2. I made a new dir: ~/sys/
  3. I checked if I have the correct nix version with nix --version (i have nix (Nix) 2.4pre-rc1)
  4. And i ran this command: nix flake init -t github:misterio77/nix-starter-config#standard
  5. Then I edited the configuration.nix to my liking
  6. And when I tried to run this command: sudo nixos-rebuild switch --flake .#hostname I get this error: error: flake 'git+file:///home/mamut/sys' does not provide attribute 'packages.x86_64-linux.nixosConfigurations."hostname".config.system.build.nixos-rebuild', 'legacyPackages.x86_64-linux.nixosConfigurations."hostname".config.system.build.nixos-rebuild' or 'nixosConfigurations."hostname".config.system.build.nixos-rebuild'

Please could someone help

Can't make overlays working

Hi, thank you for your well made config 😁
But it's taking me time to comprehend how your config works 😅
Currently i'm struggling with the overlays (i'm not really familiar with them)
My overlays look like:

# This file defines overlays
{ inputs, ... }: {
  # This one brings our custom packages from the 'pkgs' directory
  additions = final: _prev: import ../pkgs { pkgs = final; };

  # This one contains whatever you want to overlay
  # You can change versions, add patches, set compilation flags, anything really.
  # https://nixos.wiki/wiki/Overlays
  modifications = final: prev: {
    # example = prev.example.overrideAttrs (oldAttrs: rec {
    # ...
    # });
    wp4nix = import ./wp4nix.nix;
  };

  # When applied, the unstable nixpkgs set (declared in the flake inputs) will
  # be accessible through 'pkgs.unstable'
  unstable-packages = final: _prev: {
    unstable = import inputs.nixpkgs-unstable {
      system = final.system;
#      config.allowUnfree = true;
    };
  };
}

and some of my uses are:

      package = "pkgs.unstable.syncthing";

and:

{pkgs, libs, inputs, outputs, ...}:
{
    nixpkgs.overlays = [
    (final: super: {
      nginxStable = super.nginxStable.override { openssl = super.pkgs.libressl; };
    })
    (self: super: {
      wordpressPackages = pkgs.unstable.callPackage inputs.wp4nix { };
    }
    )
  ];
}

and in all the cases overlays don't seem to work
so the syncthing is using 23.05, and wp4nix is not overlayed

there's probably something else i need to show here, but i'm not sure how the logic of your config works 😥

Repo needs a license

Hello, licenses are boring I know. But if you don't include a free and open-source license, it means that the author has exclusive copyright rights. This would mean that no one can do anything with this repo.

You could for example use The Unlicense license, which is straight forward and gives everybody the right to use and modify code in this repo.

So please consider adding a free and open-source license. Thank you!

Flake Newbie: How to add a local flake to packages/devshells

hey

very cool starter config to get familiar with flakes for NixOS. (also home-manager which I haven't used before.)
Before I start: my legacy packages work fine using the pkgs/ structure. Directories with no default.nix and only a flake.nix can't be configured that way however.

Question: How do I add flakes that export a defaultPackage to this configuration?

inputs = {
...
    # custom
    bbterm = {
      url = "path:/home/benny/Code/bbterm";
      inputs.nixpkgs.follows = "nixpkgs";
    };
...
};

nix run /home/benny/Code/bbterm works fine, but downloads the nixpkgs tarball every time. I would like to have it integrated into the built nixosSystem

Thanks in advance!

error: flake does not provide attribute

I've followed the readme instructions (I am using the nix-starter-config#standard version and I have a fresh nixos installation) and used sudo nixos-rebuild switch --flake .#nixos then I am getting the following error:

error: flake 'git+file:///home/mp/nix-config' does not provide attribute 'packages.x86_64-linux.nixosConfigurations."nixos".config.system.build.nixos-rebuild', 'legacyPackages.x86_64-linux.nixosConfigurations."nixos".config.system.build.nixos-rebuild' or 'nixosConfigurations."nixos".config.system.build.nixos-rebuild'

home-manager could not find suitable profile directory.

Hi, I just started nixos on wsl.
Running nixos-rebuild is successful on my wsl, but home-manager doesn't run well. It threw out a Could not find suitable profile directory answer. The command is home-manager switch --flake /etc/nixos/#dc392@nixos.
Here's my flake.nix:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";

    home-manager.url = "github:nix-community/home-manager/release-23.11";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = {
    self,
    nixpkgs,
    home-manager,
    ...
  }@inputs: let
    inherit (self) outputs;
  in {
    nixosConfigurations = {
      "nixos" = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        specialArgs = { inherit inputs outputs; };
        modules = [
          ./nixos/configuration.nix
        ];
      };
    };

    homeConfigurations = {
      "dc392@nixos" = home-manager.lib.homeManagerConfiguration {
        pkgs = nixpkgs.legacyPackages.x86_64-linux;
        extraSpecialArgs = { inherit inputs outputs; };
        modules = [
          ./home-manager/home.nix
        ];
      };
    };
  };
}

Guess there's something wrong with the version of home-manager?
I'm new to NixOS so any help is highly appreciated.

can't import config parts like suggested in configuration.nix

configuariton.nix

...
imports = [
  ...
  # You can also split up your configuration and import pieces of it here:
  # ./users.nix
  ./locale.nix
  ...
];
...

locale.nix

{
  # Set your time zone.
  time.timeZone = "Europe/London";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_GB.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_GB.UTF-8";
    LC_IDENTIFICATION = "en_GB.UTF-8";
    LC_MEASUREMENT = "en_GB.UTF-8";
    LC_MONETARY = "en_GB.UTF-8";
    LC_NAME = "en_GB.UTF-8";
    LC_NUMERIC = "en_GB.UTF-8";
    LC_PAPER = "en_GB.UTF-8";
    LC_TELEPHONE = "en_GB.UTF-8";
    LC_TIME = "en_GB.UTF-8";
  };
}
error:
       … while calling the 'seq' builtin

         at /nix/store/09yvj6yyxspzfivv91bcxwrjxawpk1g2-source/lib/modules.nix:320:18:

          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          321|         _module = checked (config._module);

       … while evaluating a branch condition

         at /nix/store/09yvj6yyxspzfivv91bcxwrjxawpk1g2-source/lib/modules.nix:261:9:

          260|       checkUnmatched =
          261|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |         ^
          262|           let

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: getting status of '/nix/store/7l0rrwxnszvqlzw3wy1874m43g03s5dv-source/nixos/locale.nix': No such file or directory

how to use pkgs.unstable with home-manager?

Hi Misterio,

I've just updated my flake to your latest from the 'standard' dir, and I have nixos-rebuild working. But now I would like to be able to use pkgs.unstable in my home-manager's home.packages. When I'm trying to run the flake with home-manager I'm getting 'attribute unstable missing'. Do you have a solution?

Where are the actual configurations supposed to live with flake?

When following the README, the instructions here work, but what is the relationship between creating a repo and having the configuration files inside that repo, and the traditional /etc/nixos/configuration.nix, when using flakes, are the configurations under /etc/ kind of obsolete? If so I think it might be useful to clarify.

Thanks

config.news.json.output not found with home-manager standalone

I'm seeing an issue during the first run with home manager news output. When following the standard directions with home-manager (standalone on Pop!_OS) I receive the following error:

error: flake 'git+file:///home/michaelworthley/code/nix-config' does not provide attribute 'packages.x86_64-linux.homeConfigurations."username@hostname".config.news.json.output', 'legacyPackages.x86_64-linux.homeConfigurations."[email protected]' or 'homeConfigurations."username@hostname".config.news.json.output'

If I run home-manager switch --flake .#username@hostname a second time, the error does not show again.

I was able to alleviate the initial run by changing my flake to the following (which I got from nix run home-manager/[branch] -- init via the home manager documentation:

  outputs = { nixpkgs, home-manager, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs
        {
          system = "${system}";
        };
    in
...
 homeConfigurations = {
        # FIXME replace with your username@hostname
        "username@hostname" = home-manager.lib.homeManagerConfiguration {
          inherit pkgs;
          extraSpecialArgs = { inherit inputs; }; # Pass flake inputs to our config
          # > Our main home-manager configuration file <
          modules = [ ./home-manager/home.nix ];
        };
      };
    };

I figure the error is not a blocker but as a new Nix user I was confused for a bit. I'm not exactly sure why that fixed it for me, but I figure is has to to with the way nixpkgs is being imported. Hopefully this issue help anyone else who has run into something similar or if anyone know the "why" behind this I would love to learn more!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.