hello everyone! noob here… ![]()
so, about -> follows 'nixpkgs'…
what should one use that for, if a flake works just fine without it? is it for compilation tools or something? because if every flake uses its own built-in, independent compilation tools, does that mean that with PKG.inputs.nixpkgs.follows = "nixpkgs" one can use system packages and compilation tools instead? okay, then, how do i even know that it does, indeed, do exactly that? i.e. how do i see if it builds / compiles using my own compilers from my systemPackages / nixpkgs? or did i get that completely wrong and am a fool? e.g.:
inputs = {
# ...
yazi.url = "github:sxyazi/yazi"; # necessary for installation
# yazi.inputs.nixpkgs.follows = "nixpkgs"; # not necessary?!
};
sometimes, the latter line could lead to compilation errors and to hash mismatches in fixed-output derivations. but why?
how does one know when is it possible to use a PKG.inputs.nixpkgs.follows = "nixpkgs"? do you actually have to look at each and every flake to see if it supports it?
okay, here is another one: i just want A package from a flake which is NOT in the main nixpkgs repo (is that how you say it?). a singular package. that’s it. is this the bare minimum for unstable?
flake.nix
{
description = "help me"; # is *description* even required?
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
yazi.url = "github:sxyazi/yazi"; # file manager
};
outputs = {
self,
nixpkgs,
# yazi, # do you need this output? why?
...
} @inputs: # sorry what? WHAT IS THIS?!?!
# sometimes they do even THIS:
# @inputs: let inherit (self) outputs; in # WTF?!
{ nixosConfigurations.HOST = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; # LEGACY?! do you still need this?
specialArgs = {
inherit inputs; # why? why? whyyyy?!
# or
# inherit inputs outputs PKG; # please help me
# or
# inherit inputs nixpkgs; # i am utterly lost
};
# ...
# sometimes people have more stuff HERE
# ...
modules = [
./configuration.nix # understandable
# ./hardware-configuration.nix # NOT understandable!!
# yazi.nixosModules.default # unnecessary? why would you want this?
];
};
};
# ...
# again, some people have EVEN MORE stuff down here!
# ...
}
configuration.nix
{
config, # config = { }
lib, # mkDefault mkForce
pkgs,
inputs, # flakes
...
}:
{
# ...
environment.systemPackages = {
inputs.yazi.packages.${pkgs.system}.default;
# okay, SLOW DOWN. what is all of this:
# ${pkgs.system}?
# is it the same as
# ${pkgs.stdenv.hostPlatform.system}?
# next, why doesnt it work without *inputs.*?!
# in some guides they just tell you to
# "place the pkgs.PKG in *systemPackages*"
# but it never worked!
};
# ...
}
lastly, this question bothers me the most. could be a little silly, but i do need to ask this:
for example, i am NOT using nixos-unstable, rather, i am using nixos-unstable-small. do you have to accommodate for the prefix or not? for example:
inputs = {
# nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-small.url = "github:nixos/nixpkgs/nixos-unstable-small";
yazi.url = "github:sxyazi/yazi";
yazi.inputs.nixpkgs.follows = "nixpkgs-small"; # is that right?
};
i just really want to understand this before i go ahead and try home-manager. which has like 3 different ways of installation inside a flake.nix: the external .nix file configuration, the nixosModules configuration - the one that is strangely without the equals mark before { }, and a separate homeConfigurations."USER@HOST" = home-manager.lib.homeManagerConfiguration - all of them are just… infinitely interesting.
sorry, it surely is quite a bit silly, but, yeah… thanks in advance!!! ![]()
P.S. i DONT use yazi nor home-manager…
LATE EDIT: hey guys, future me here. dont wanna bump this, but here is how i do it nowadays. pls let me know if this is bad practice lol.
so im gonna show u how to install a flake package and extra flake options, such examples are niri and hjem respectively:
flake.nix
{
inputs.nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz";
# ^ this doesnt use github at all and shrinks size! ^
niri.url = "github:niri-wm/niri"; # package(s) example
niri.inputs.nixpkgs.follows = "nixpkgs";
# ^ this uses system nixpkgs and shrinks size! ^
hjem.url = "github:feel-co/hjem"; # option(s) example
hjem.inputs.nixpkgs.follows = "nixpkgs";
# ^ ditto, uses system packages when building! ^
outputs = inputs: { # shortens a duplicate list...
nixosConfigurations.HOSTNAME = inputs.nixpkgs.lib.nixosSystem { # FIXME!
specialArgs.inputs = inputs; # same as "inherit inputs"
modules = [
./configuration.nix # inputs
# niri flake is just a package without options!
inputs.hjem.nixosModules.default # options
];
};
};
}
^ well technically every module contains a package, but y’know what i mean, right?
configuration.nix
{
config, # shortens the options
inputs, # passes the flakes
lib, # the "lib" part in "pkgs.lib.mkForce" et al
pkgs, # the "pkgs" part in "pkgs.niri"
... # the rest of the dictionary
}: { # actual "config.*" shorthand per se
programs.niri.enable = true; # vanilla nixos
programs.niri.package = inputs.niri.packages.${pkgs.stdenv.hostPlatform.system}.default;
# ^ comes from "niri.url" in "flake.nix" ^
# ^ its very messy, but it works! ^
hjem.users.USERNAME.enable = true;
# ^ comes from "inputs.hjem.nixosModules.default" in "flake.nix"
hjem.users.USERNAME.files.".bashrc".text = "";
# ^ just for show, creates empty ".bashrc" at "$HOME" ^
}
and thats it! to update the system, i use nh (nix helper). since i keep my configuration.nix and flake.nix in $XDG_CONFIG_HOME/nixos ($HOME/.config/nixos), i have to set a path:
configuration.nix
programs.nh.enable = true; # vanilla nixos
programs.nh.flake = "$HOME/.config/nixos"; # sets $NH_FLAKE
# ^ it cant find "$XDG_CONFIG_HOME" for some reason? ^
after which nh commands will be available, so that i could update everything with these:
A) if i want a full system update (with flake inputs, SLOW):
nh os switch --ask --diff=always --keep-going --update --verbose
B) if i want to refresh configuration.nix (without flake inputs, FAST):
nh os switch --diff=always --keep-going
anyway im not gonna yap about how to use literally anything, but this was relevant to my usage of flakes lol
…so yeah! that is how i use my little nixos system! i am very much chaotic, so i dont “split” my configs or anything, everything is all piled up in one file, dont care. ive been saying this for a long time now, but i still dont have my own repo. i really wanna share this, but its not ready even at 20k lines… bye bye!!!
^ END OF LATE EDIT ^