Hey folks, this is driving me crazy. I’m trying to setup a new harddrive with Nix, and am now trying to migrate it to a flake. I’m getting this:
[mcrowe@xps15:~/Programming/Personal/nix-os/mike-nixos]$ nix shell
warning: Git tree '/home/mcrowe/Programming/Personal/nix-os/mike-nixos' is dirty
error: flake 'git+file:///home/mcrowe/Programming/Personal/nix-os/mike-nixos' does not provide attribute 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'
If I do a nix flake show
, I get:
[mcrowe@xps15:~/Programming/Personal/nix-os/mike-nixos]$ nix flake show
warning: Git tree '/home/mcrowe/Programming/Personal/nix-os/mike-nixos' is dirty
git+file:///home/mcrowe/Programming/Personal/nix-os/mike-nixos
├───devShells
│ ├───aarch64-darwin
error: expected a derivation
I’m trying to cobble together my preferred config based on other users examples, and I can’t seem to find the right setup. Any advice?
flake.nix
: (based off misterio77 started configs by/large)
{
description = "Mike's system configuration";
inputs = {
# Unstable Branch
# nixpkgs.url = "nixpkgs/nixos-unstable";
# nixpkgs-unstable.url = "nixpkgs/master";
# flake-parts.url = "github:hercules-ci/flake-parts";
# Stable Branch
nixpkgs.url = "nixpkgs/nixos-23.05";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
# TODO: Add any other flake you might need
# hardware.url = "github:nixos/nixos-hardware";
};
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
inherit (self) outputs;
forAllSystems = nixpkgs.lib.genAttrs [
# "aarch64-linux"
# "i686-linux"
"x86_64-linux"
"aarch64-darwin"
# "x86_64-darwin"
];
in
rec {
# Your custom packages
# Acessible through 'nix build', 'nix shell', etc
packages = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in { default = import ./pkgs { inherit pkgs; }; }
);
# Devshell for bootstrapping
# Acessible through 'nix develop' or 'nix-shell' (legacy)
devShells = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in { default = import ./shell.nix { inherit pkgs; }; }
);
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
# Your custom packages and modifications, exported as overlays
overlays = import ./overlays { inherit inputs; };
# Reusable nixos modules you might want to export
# These are usually stuff you would upstream into nixpkgs
nixosModules = import ./modules/nixos;
# Reusable home-manager modules you might want to export
# These are usually stuff you would upstream into home-manager
homeManagerModules = import ./modules/home-manager;
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = {
xps15 = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; }; # Pass flake inputs to our config
system = "x86_64-linux";
modules = [
# > Our main nixos configuration file <
./hosts/laptop/configuration
];
};
};
# Standalone home-manager configuration entrypoint
# Available through 'home-manager --flake .#your-username@your-hostname'
homeConfigurations = {
"mcrowe@xps15" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
specialArgs = { inherit inputs; }; # Pass flake inputs to our config
modules = [
# > Our main home-manager configuration file <
./home-manager/home.nix
];
};
};
};
}
My shell.nix
:
{ pkgs }:
with pkgs;
mkShell {
name = "flakeEnv";
buildInputs = [ rnix-lsp ];
shellHook = ''
alias nrb="nixos-rebuild build --flake ."
alias nrt="sudo nixos-rebuild test --flake ."
alias nrs="sudo nixos-rebuild switch --flake ."
alias build-laptop="nixos-rebuild switch --flake .#laptop"
'';
}