this post was submitted on 22 Jul 2025
52 points (98.1% liked)

Linux

56779 readers
630 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

One aspect of Guix I found to be really fascinating: That there is basically no conceptual difference between defining a package as a private build script, and using a package as part of the system.

Let me explain: Say you wrote a little program in Python which uses a C library (or a Rust library with C ABI) which is in the distribution. Then, in Guix you would put that librarie's name and needed version into a manifest.scm file which lists your dependency, and makes it available if you run guix shell in that folder. It does not matter whether you run the full Guix System, or just use Guix as s package manager.

Now, if you want to install your little python program as part of your system, you'll write an install script or package definition, which is nothing else than a litle piece of Scheme code which contains the name of your program, your dependency, and the information needed to call python's build tool.

The point I am making is now that the only thing which is different between your local package and a distributed package in Guix is that distributed packages are package definitions hosted in public git repos, called 'channels'. So, if you put your package's source into a github or codeberg repo, and the package definition into another repo, you now have published a package which is a part of Guix (in your own channel). Anybody who wants to install and run your package just needs your channel's URL and the packages name. It is a fully decentral system.

In short, in Guix you have built-in something like Arch's AUR, just in a much more elegant and clean manner - and in a fully decentralized way.

you are viewing a single comment's thread
view the rest of the comments
[–] iopq@lemmy.world 2 points 6 days ago (8 children)

Bash is not a advantage, it's a disadvantage

[–] msherburn33@lemmy.ml 1 points 6 days ago (7 children)

You prefer:

     (add-after 'install 'remove-examples
       (lambda* (#:key outputs #:allow-other-keys)
         (with-directory-excursion
             (string-append (assoc-ref outputs "out") "/lib")
           (for-each delete-file
                     (list
                      "basic-server"
                      "helloworld"
                      "postcollector")))

over:

postInstall = ''
   rm  $out/lib/basic-server $out/lib/helloworld $out/lib/postcollector
''

?

[–] HaraldvonBlauzahn@feddit.org 0 points 6 days ago* (last edited 6 days ago) (4 children)

Yes, having programmed bash and its predecessors for 30 years and several lisps (Clojure, Racket, Guile, a little SBCL) in the last 15 years, I very much prefer the Scheme version in this place.

Why?

  • This code fragment is part of a much larger system, so readability and consistency counts
  • The Guile version supports a more powerful functionality, which is that evaluation of a package can have several extra results (called outputs). It is over a year that I read about that in the Guix documentation and yet I recognize it immediately.
  • the code tells me that it is removing examples.
  • the code fits neatly into a tidy system of several stages of build and packaging
  • the code uses a structured loop. Of course you can do that in shell as well - I am pointing this out because the bash version is a bit shorter because it does not use a loop.
  • Scheme has much safer and more robust string handling. The code will not do harmful things if a file name contains white space or happens to be equal to 'echo a; rm -rf /etc/*'.
  • Scheme strings handle Unicode well
  • If there is an error, it will not be silently ignored as is the norm in shell scripts which are not written by experts, but will throw it.
  • the code has less redundancy. For example, the bash version mentions three times the subfolder "lib", the Guile version only once. This makes it easier to refactor the code later.
[–] balsoft@lemmy.ml 1 points 6 days ago

I agree with your overall point, that having a single consistent functional language for package descriptions and build scripts is a great thing, and that bash is awful, but your reasoning is somewhat flawed. The main drawbacks of bash are somewhat rectified in Nix because bash is very much contained/sandboxed, which prevents arbitrary damage to the system, and there are some nice defaults in stdenv too.

The Guile version supports a more powerful functionality, which is that evaluation of a package can have several extra results (called outputs). It is over a year that I read about that in the Guix documentation and yet I recognize it immediately.

Nix also supports multiple outputs (in fact this is where the concept of outputs in Guix came from)

the code tells me that it is removing examples.

You could also do that with Nix in an easier and more declarative fashion, either by adding a comment, or by doing this:

postInstallPhases = [ "removeExamplesPhase" ];
removeExamplesPhase = ''
  rm -f "$out"/lib/{basic-server,helloworld,postcollector}
'';

Scheme has much safer and more robust string handling. The code will not do harmful things if a file name contains white space or happens to be equal to 'echo a; rm -rf /etc/*'.

Bash is just two double quotes away from doing this too. See code above for an example

Scheme strings handle Unicode well

Bash also handles Unicode well

If there is an error, it will not be silently ignored as is the norm in shell scripts which are not written by experts, but will throw it.

Nixpkgs stdenv sets set -eu which has a similar effect. If that code fails, the entire build will fail too.

the code has less redundancy. For example, the bash version mentions three times the subfolder “lib”, the Guile version only once. This makes it easier to refactor the code later.

This is also really quite easy to rectify in bash, see code above.

load more comments (3 replies)
load more comments (5 replies)
load more comments (5 replies)