My biggest blog post yet, and it’s about running (almost) vanilla NixOS on a (formerly) Android phone! This was 50% fun and 50% exhausting… you solve one issue and another one crops up right away… it was certainly an interesting educational experience.

I’m not explaining any basic technical concepts here, as I’m not a complete noob in phone ROMs and Linux.

Ask me any questions if you have them!

    • chayleaf@lemmy.mlOP
      link
      fedilink
      arrow-up
      0
      ·
      11 months ago

      strictly speaking, NixOS doesn’t have repositories.

      NixOS has “derivations” (rules are written in the Nix language to generate a script that builds a package, which is called a derivation - yes, everything is built from source to the extent possible/reasonable) and “platforms” (the system that builds the derivation OR the system the derivation is built for). A “platform” is e.g. the CPU architecture, the libc used, the target kernel (there’s most support for Linux and Darwin, which is the macOS kernel, but e.g. FreeBSD is supported to some extent too). The derivation code may well be shared across platforms, though often platform-specific workarounds are required.

      Of course, different platforms have different support. Some platforms have derivations from nixpkgs (the NixOS git repo) regularly built for them and put into the official binary cache (which stores the derivation outputs, i.e. ready-built packages for a certain set of inputs, which generally match what you would’ve built from source because Nix strives for reproducibility, you’re still free to override a package’s inputs and build it from source). linux-aarch64 is one of such platforms. Other platforms may only have a small set of core packages like gcc built for them, or simply require building absolutely everything from source.

      The reason nixpkgs is not a repository (though I guess you could call it one) is because it only provides rules to build a package, but not the package itself. Some derivations (e.g. for Gog games) even require you to add some non-redistributable files to the Nix store manually. The derivations may or may not build correctly for each platform they’re supposed to work on.

      The reason the binary cache is not a repository is because it’s just a cache for nixpkgs - it stores every derivation’s output (if the build doesn’t fail), even if that derivation is one that downloads a package’s source code (yes, that’s a derivation too), even if the derivation is from many years ago (which has historical value, as you can revert nixpkgs to an old version and still be able to download prebuilt versions of packages).

      Together, they form something like a repository, but it’s still way too different. For example, unlike on Arch, I can stay on the same nixpkgs version for a long time without updating, which I really prefer because I have to build 3 kernels on each update, since I’m syncing the nixpkgs version of my 4 NixOS devices, only 1 of which doesn’t require a custom kernel config. Or I can always revert back to an older version of nixpkgs if a new one breaks something and it will still work. Or I can fork nixpkgs and change some stuff, and the stuff with changed inputs will have to be rebuilt locally, with stuff that didn’t change still available from the binary cache.

        • Laser@feddit.de
          link
          fedilink
          arrow-up
          0
          ·
          edit-2
          11 months ago

          It’s rather closer to something like ports or Gentoo’s ebuild repository, though it doesn’t have USEFLAGS, but it’s still more flexible than the AUR. In general, Arch’s PKGBUILDs are rather simple bash scripts, while Nixpkgs has functions dedicated to making derivations, mostly mkDerivation. For example, see https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/he/hello/package.nix for the derivation definition for hello. There’s no stuff like ./configure, makeetc. in there (though `mkDerivation does this under the hood of course). You rather define the derivation in a declarative way as much as possible and the build system does the rest.

          Edit: What actually provides binaries to users is the Hydra cache. Hydra is a continuous build system that tries to make sure the derivations in Nixpkgs actually compile (and work, but this requires tests and not all derivations ship those), and then also provides these built derivations to users. This substitutes your own build output. https://search.nixos.org/options?channel=unstable&show=nix.settings.substituters