hallettj

joined 2 years ago
[–] hallettj@beehaw.org 1 points 9 months ago

Well ok, they both use symlinks but in different ways. I think what I was trying to say is that in NixOS it's symlinks all the way down.

IIUC on Fedora Atomic you have an ostree image, and some directories in the image are actually symlinks to the mutable filesystem on /var. Files that are not symlinks to /var (and that are not inside those symlinked directories), are hard links to files in the ostree object store. (Basically like checked-out files in a git repository?)

On NixOS this is what happens if examine what's in my path:

$ which curl
/run/current-system/sw/bin/curl

$ ls -l /run | grep current-system
/run/current-system -> /nix/store/p92xzjwwykjj1ak0q6lcq7pr9psjzf6w-nixos-system-yu-23.11.20231231.32f6357

$ ls -l /run/current-system/sw/bin/curl
/run/current-system/sw/bin/curl -> /nix/store/r304lglsa9i2jy5hpbdz48z3j3x2n4a6-curl-8.4.0-bin/bin/curl

If I select a previous configuration when I boot I would get a different symlink target for /run/current-system. And what makes updates atomic is the last step is to switch the /run/current-system symlink which switches over all installed packages at once.

I can temporarily load up the version of curl from NixOS Unstable in a shell and see a different result,

$ nix shell nixpkgs-unstable#curl  # this works because I added nixpkgs-unstable to my flake registry
$ which curl
/nix/store/0mjq6w6cx1k9907vxm0k5pk7pm1ifib3-curl-8.4.0-bin/bin/curl  # note the hash is different

I could have a different version curl installed in my user profile than the one installed system-wide. In that case I'd see this:

$ which curl
/home/jesse/.nix-profile/bin/curl

$ ls -la /home/jesse | grep .nix-profile
.nix-profile -> /nix/var/nix/profiles/per-user/jesse/profile

$ ls -l /nix/var/nix/profiles/per-user/jesse
profile -> profile-133-link
profile-130-link -> /nix/store/ylysfs90018zc9k0p0dg7x6wvzqcq68j-user-environment
profile-131-link -> /nix/store/9hjiznbaii7a8aa36i8zah4c0xcd8w6d-user-environment
profile-132-link -> /nix/store/h4kkw1m5q6zdhr6mlwr26n638vdbbm2c-user-environment
profile-133-link -> /nix/store/jgxhrhqiagvhd6g42d17h4jhfpgxsk3n-user-environment

Basically symlinks upon symlinks everywhere you look. (And environment variables.)

So I guess at the end everything is symlinks on NixOS, and everything is hard links plus a set of mount paths on Fedora Atomic.

[–] hallettj@beehaw.org 1 points 9 months ago (2 children)

"Atomic" is a catchy descriptor! Atomic distros for the Atomic Age! It could be an umbrella term since NixOS and Guix are atomic, but instead of images and partitions they use symlinks, and patch binaries to use full paths for libraries and programs that they reference. So there are image-based distros, and I guess expression-derived distros which are both atomic.

I haven't tried image-based distros. This post fills in some gaps for me. Thanks for the write-up!

[–] hallettj@beehaw.org 1 points 9 months ago

Oh this is just the thing for playing bard, and casting "vicious mockery" several times per combat

 

Posting just because I looked all over and didn't see an answer. This function expands its arguments to canonical, absolute file paths, and tests whether one is a string prefix of the other. It also works for checking whether a directory is inside of or is identical to another directory.

local is_file_in_directory = function(file_path, directory_path)
  local file = vim.fn.fnamemodify(file_path, ':p')
  local dir = vim.fn.fnamemodify(directory_path, ':p')
  return file ~= nil and dir ~= nil and
      -- is dir an initial substring of file?
      file:find(dir, 1, true) == 1
end

This came up because I'm setting up obsidian.nvim which looks like a handy way to get the best of both worlds between Obsidian and Neovim. I'm setting up some custom configuration to automatically change the selected Obsidian workspace when I cd into vault directory, and to set conceallevel = 1 only on files in a vault, and that requires checking whether the working directory or a file path is inside a given vault directory.

[–] hallettj@beehaw.org 0 points 11 months ago (1 children)

Radium produces the most radiation by miles. The plutonium gives off some alpha radiation that won't hurt you if you don't eat it. (Eye protection would be a good idea I suppose.) I don't remember what U-235 emits but I don't think it's a huge amount.

[–] hallettj@beehaw.org 0 points 11 months ago (1 children)

I think NixOS is awesome, but it certainly doesn't offer "access to (basically) all Linux-capable software, no matter from what repo." - at least not natively.

I don't quite agree with this. In NixOS you can write custom expressions that fetch software from any source, and stitch them into your configuration as first-class packages. So you do get access to all Linux-capable software natively, but not necessarily easily. (There is a learning curve to packaging stuff yourself.)

I use this process to bring nightly releases of neovim and nushell into my reproducible config. Ok, I do use flakes that other people published for building those projects, which is a bit like installing from a community PPA. But when I wanted to install Niri, a very new window manager I wrote the package and NixOS module expressions all by myself!

 

This is something that I struggle with. I know how to find top-level packages like git or cowsay. But what about utilities under nested paths? I always spend ages digging through the nixpkgs source code to try to find utilities to use in my nix expressions.

Today I want to use buildRustPackage. It's defined here, and is propagated here. But how do I access it given a pkgs variable? I have no idea!

https://search.nixos.org/packages is no help

nix search nixpkgs doesn't find it

I think I need to search by attribute name, not by derivation name. But I don't know how to do that.

1
submitted 1 year ago* (last edited 1 year ago) by hallettj@beehaw.org to c/nixos@lemmy.ml
 

It took me a while to figure this out. I use Home Manager to manage my Gnome settings by setting dconf.settings = { ... }. My settings are non-trivial (for example my paperwm module). So it's helpful for me to check the actual dconf settings that Home Manager produces.

To do that build your configuration with home-manager build, open result/activate, and find a line that looks like this:

$DRY_RUN_CMD $DCONF_DBUS_RUN_SESSION /nix/store/4ab7dx08wx640444m71axlqvbrvz73bv-dconf-0.40.0/bin/dconf load / 
  < /nix/store/0hdnvwx8d9sifd6ib8n2hhblyblq0ccp-hm-dconf.ini

The store path for hm-dconf.ini has the settings.

Edit: added a line break to the script line so you can see the relevant store path

[–] hallettj@beehaw.org 0 points 1 year ago (1 children)

But Flatpak has its fancy "portals" to connect each app with the specific resource it needs which you don't get with Docker.

Also if the goal is to limit access of apps you don't want to fully trust, I think Docker doesn't have the appropriate security properties. Here's a quote from the readme for Bubblewrap (the sandboxing tool that Flatpak and Nixpak use),

Many container runtime tools like systemd-nspawn, docker, etc. focus on providing infrastructure for system administrators and orchestration tools (e.g. Kubernetes) to run containers.

These tools are not suitable to give to unprivileged users, because it is trivial to turn such access into a fully privileged root shell on the host.

 

I have a workaround so this isn't exactly a problem for me. I'm just curious about what is going on, and what best practices are.

I'm setting up Arion. I think it will be helpful for my development flow in a project where I have several services that need to run and communicate with each other. Docker-compose is a nice way to handle this, but you have to have a Docker image to run, and it's a pain to create a new image after each code change. OTOH Arion will run an arbitrary command, and creates Nix-friendly images automatically. Very promising!

The Nix expression for the service I'm developing is exported from a flake, while the arion executable reads its configuration from a Nix expression that is not a flake. There is an example configuration that recommends importing a flake using builtins.getFlake which you can see here: https://github.com/hercules-ci/arion/blob/main/examples/flake/arion-pkgs.nix

The problem is that builtins.getFlake is slow. It adds >20s to every arion command I run. That includes starting services, reading logs, removing stopped containers, etc.

The example config includes a fallback that loads the flake using flake-compat instead of builtins.getFlake. When I use flake-compat loading the flake is nearly instant.

So I'm using flake-compat, and that seems to be working. (Many thanks to the flake-compat author!) But I'm curious why builtins.getFlake is so slow.

 

I've had a problem making commits with fugitive for a long time, over a number of versions of Neovim. Has anyone seen this error before? I've searched a number of times but not found anything.

I use the cc binding in a fugitive window to open a split to write a commit message. Then I run :x to close the split and finish the commit. Most times - but not every time - I get this error message, the commit is not made, and the fugitive window becomes blank.

g`"                                                                                                                            
Error detected while processing BufEnter Autocommands for "fugitive://*//"..function 81_ReloadWinStatus[11]..81_Reloa
dStatusBuffer[6]..fugitive#BufReadStatus[364]..BufEnter Autocommands for "fugitive://*//"..function 81_ReloadWinStatus[11]
..81_ReloadStatusBuffer[6]..fugitive#BufReadStatus[292]..BufReadPost Autocommands for "*"..function fugitive#Resume[5]..<s>81_RunWait:                                                                                                                 
line   29:                                                                                                                     
E242: Can't split a window while closing another

I don't know what the deal is with the g`" line in messages. That might be a clue?

This does not happen when I make a commit without writing a message - for example when I use ce to amend the last commit without editing the commit message.

 

Instead of getting plugins through nixpkgs I prefer to use my neovim-specific plugin manager. (In my case that's lazy.nvim.) Mostly this works without problems - but some setup is required when a plugin needs to compile something. The plugin that has given me the most trouble is Treesitter which wants to compile grammars. Here is how I got that working.

tl;dr: Configure Treesitter to compile grammars with gcc instead of clang.

As has been reported in https://github.com/nvim-treesitter/nvim-treesitter/issues/1449 Treesitter will try to use clang to compile Treesitter grammars, and on NixOS for some reason clang is not able to locate necessary C++ libraries. The fix that works for me is to configure Treesitter to use gcc instead. Here is the relevant part of my plugin config:

return {
  'nvim-treesitter/nvim-treesitter',
  build = ':TSUpdate',
  config = function()
    -- Set compiler to get grammar installation working in NixOS. See
    -- https://github.com/nvim-treesitter/nvim-treesitter/issues/1449
    require('nvim-treesitter.install').compilers = { 'gcc' }
    require('nvim-treesitter.configs').setup {
      ensure_installed = 'all', -- "all", or list of languages
      ignore_install = { 't32' }, -- t32 is failing to download for me
    }
  end,
}

I still had a problem with the t32 grammar, but I don't need that one so I disable it.

Of course you need to make sure that gcc is available. You could put it in your user profile, but I prefer to make sure by using the extraPackages option from Home Manager's neovim module. Here's my full config:

programs.neovim = {
  enable = true;
  defaultEditor = true;
  withPython3 = true;
  extraPackages = with pkgs; [
    fd
    gh # for github integration
    ripgrep

    # needed to compile fzf-native for telescope-fzf-native.nvim
    gcc
    gnumake

    # language servers
    nil # Nix LSP
    lua-language-server

    nixpkgs-fmt # I have nil configured to call this for formatting
  ];
};
[–] hallettj@beehaw.org 0 points 1 year ago (1 children)

I think these are ebooks. You can self-publish online for free so there isn't much of a barrier to putting something out there, and hoping a few people fall for it and buy copies.

[–] hallettj@beehaw.org 0 points 1 year ago (1 children)

I've had ls aliased to exa for a while. So it looks like eza is a fork of exa? The git feature looks interesting.

 

I've been searching for a way to do this, but I haven't found anything. After I have refactored my Home Manager configuration is there a way I can test the changes in a shell before I switch?

From what I understand the next-best option is to switch, and then find and run the activate script of the previous generation to switch back.

[–] hallettj@beehaw.org 0 points 1 year ago (1 children)

There is another thread on this with a bunch of links: https://beehaw.org/post/502245

 

I'm moving soon and I won't have access to my desktop computer for a few weeks. I'm shopping for a laptop to continue my programming work during that time, and as a supplement for later when I want portability. Does anyone here have a favorite?

I made my own mechanical Bluetooth keyboard that I want to use; so I'm curious about 2-in-1 or tablet devices where the keyboard can be put out of the way, or even excluded.

I'm looking for:

  • portability over power
  • but enough power to run Rust Analyzer without being painfully slow
  • high-resolution screen
  • doesn't have to be the latest model

I'm a longtime fan of the Dell XPS 13, but I haven't tried any of the 2-in-1 versions. The Asus Zenbook Flip also looks promising.

I'm thinking of trying out Nix' remote builds feature to shift load away from the local processor and RAM. But I'm sure that won't funny eliminate the need for some local processing power. It'll be interesting to find out.