!lTqhfnNvIkcEackxxk:matrix.org

Nix Bindings

69 Members
Nix C API https://github.com/NixOS/nix/blob/master/doc/manual/src/c-api.md, language-specific bindings, and their use cases (currently broken link: https://nixos.org/manual/nix/unstable/c-api)18 Servers

Load older messages


SenderMessageTime
13 Dec 2024
@raboof:matrix.orgraboof joined the room.14:58:31
17 Dec 2024
@btyby:matrix.org@btyby:matrix.org joined the room.18:34:16
@btyby:matrix.org@btyby:matrix.org left the room.18:38:45
21 Dec 2024
@dimitarnestorov:matrix.orgDimitar joined the room.19:47:35
26 Dec 2024
@o-santi:matrix.orgLeonardo Santiagohello guys22:04:18
@o-santi:matrix.orgLeonardo Santiagolet's say that I'm trying to describe a derivation from the C side, and would like to get it built on the store, how would I achieve it?22:05:28
@o-santi:matrix.orgLeonardo Santiago I'm interested in replicating the internals of nix develop with added quirks using the FFI, but it seems to fiddle too much with derivations, much more than it seems to be available in the C API 22:07:46
@o-santi:matrix.orgLeonardo SantiagoI've already managed to get some basic derivation parsing going on, and I can make the same changes that are done in the nix side just fine, but there doesn't seem to be any way to write them back to the store?22:09:11
@o-santi:matrix.orgLeonardo Santiago I'm specifically talking about $nix/src/nix/develop.cc#L285: 22:10:10
@o-santi:matrix.orgLeonardo Santiago *

I'm specifically talking about $nix/src/nix/develop.cc#L285:

    auto shellDrvPath = writeDerivation(*evalStore, drv);

    /* Build the derivation. */
    store->buildPaths(
        { DerivedPath::Built {
            .drvPath = makeConstantStorePathRef(shellDrvPath),
            .outputs = OutputsSpec::All { },
        }},
        bmNormal, evalStore);


22:10:24
@o-santi:matrix.orgLeonardo Santiago the closest function that is there is nix_store_realise, but even then it expects a store path and there isn't any way to create files in the store, other than writing a custom derivation as a string and evaluating it. how should I proceed? 22:12:20
@o-santi:matrix.orgLeonardo Santiago* I've already managed to get some basic derivation parsing going on, and I can make the same changes that are done in the C++ side just fine, but there doesn't seem to be any way to write them back to the store?22:13:53
@o-santi:matrix.orgLeonardo Santiago *

I'm specifically talking about $nix/src/nix/develop.cc#L285:

    auto shellDrvPath = writeDerivation(*evalStore, drv);

    /* Build the derivation. */
    store->buildPaths(
        { DerivedPath::Built {
            .drvPath = makeConstantStorePathRef(shellDrvPath),
            .outputs = OutputsSpec::All { },
        }},
        bmNormal, evalStore);
22:14:09
@o-santi:matrix.orgLeonardo Santiago *

I'm specifically talking about $nix/src/nix/develop.cc#L285-293:

    auto shellDrvPath = writeDerivation(*evalStore, drv);

    /* Build the derivation. */
    store->buildPaths(
        { DerivedPath::Built {
            .drvPath = makeConstantStorePathRef(shellDrvPath),
            .outputs = OutputsSpec::All { },
        }},
        bmNormal, evalStore);
22:14:27
27 Dec 2024
@dimitarnestorov:matrix.orgDimitar set a profile picture.11:41:14
@dimitarnestorov:matrix.orgDimitar changed their display name from dimitarnestorov to Dimitar.11:42:12
28 Dec 2024
@jay.hay:matrix.org@jay.hay:matrix.org joined the room.15:02:03
@mjolnir:nixos.orgNixOS Moderation Bot banned @jay.hay:matrix.org@jay.hay:matrix.org (spam).15:02:04
30 Dec 2024
@mariaeduarda0c:matrix.orgmariaeduarda0c joined the room.00:55:19
@roberthensing:matrix.orgRobert Hensing (roberth) Leonardo Santiago: we don't have much of a C API for the Store yet, but more importantly nix develop is architecturally unsound and we should move most of that logic to Nixpkgs anyway because of the bad coupling. See https://github.com/NixOS/nix/issues/7501 13:19:13
@roberthensing:matrix.orgRobert Hensing (roberth)So if you were to reimplement parts of develop with the C API, you'd end up duplicating those problems, and you won't support user-defined shell runners13:20:18
@roberthensing:matrix.orgRobert Hensing (roberth)(We would welcome additions to the libstore C API; that's not a problem)13:21:40
@o-santi:matrix.orgLeonardo Santiago
In reply to @roberthensing:matrix.org
So if you were to reimplement parts of develop with the C API, you'd end up duplicating those problems, and you won't support user-defined shell runners
yes, I very much noticed that, and I'd love if the environment variable handling logic was done entirely in nix
14:42:47
@o-santi:matrix.orgLeonardo Santiago the problem I'm trying to tackle is turning a derivation into a runnable shell. it seems to me that all that needs to be done is concatenating the buildInputs paths and running the shellHook as the --rcfile 14:51:13
@o-santi:matrix.orgLeonardo Santiago but looking at the develop c++ code, there are a bunch of stuff going on, including creating another derivation to export env vars as json, running it, parsing from json, and so on 14:52:50
@o-santi:matrix.orgLeonardo Santiagois there any simple way to replicate that behavior without having to mimic the c++ code? i don't really understand what constraints are at play here so for me it seems just overcomplicating for (seemingly) no reason, but I'm sure there's some motive behind all this14:54:27
31 Dec 2024
@zantonarthwyng:matrix.org@zantonarthwyng:matrix.org joined the room.01:10:59
1 Jan 2025
@zantonarthwyng:matrix.org@zantonarthwyng:matrix.org removed their display name zantonarthwyng.06:39:36
@zantonarthwyng:matrix.org@zantonarthwyng:matrix.org left the room.06:43:45
@butterbohn:matrix.org@butterbohn:matrix.org joined the room.11:35:50

Show newer messages


Back to Room ListRoom Version: 10