Thx for the reply. This is what I did:
In flake.nix from ARTIQ:
vivado = pkgs.buildFHSEnv {
name = "vivado";
targetPkgs = vivadoDeps;
profile = "set -e; source /mnt/c/Xilinx/Vivado/2022.2/settings64.sh";
runScript = "vivado";
};

In flake.nix from ARTIQ-zynq:
'inputs.artiq.url = "path:/mnt/c/Users/lf/Documents/codes/hardware/artiq/artiq"
'

Following the instructions in the manual I typed nix flake update and nix develop after every flake.nix change and got messages showing my changes.

I also changed the build command:
nix build --print-build-logs --impure --expr 'let fl = builtins.getFlake "/mnt/c/Users/lf/Documents/codes/hardware/artiq/artiq-zynq"; in (fl.makeArtiqZynqPackage {target="kasli_soc"; variant="standalone"; json=./default.json;}).kasli_soc-standalone-sd'

I will continue looking for the origin of the error.

    Thanks for the reply. I tried to substitute the extra-sandbox-paths="/opt" to the location of my vivado with what you suggest, as well as with /mnt/c, but I still get the same error.

    Hi again,
    I decided to do it on Linux and installed everything as is suggested in the instructions. Given that all is the same, once I downloaded the artiq-zynq pachage (its release-8), I just executed nix develop and then nix build --print-build-logs --impure --expr 'let fl = builtins.getFlake "git+https://git.m-labs.hk/m-labs/artiq-zynq?ref=release-8"; in (fl.makeArtiqZynqPackage {target="kasli_soc"; variant="standalone"; json=./basic.json;}).kasli_soc-standalone-sd'

    The error I get is the same:
    kasli_soc-standalone-gateware> Fastino (EEM0) starting at RTIO channel 0x000000
    kasli_soc-standalone-gateware> USER LED at RTIO channel 0x000001
    kasli_soc-standalone-gateware> USER LED at RTIO channel 0x000002
    kasli_soc-standalone-gateware> /etc/profile: line 37: /opt/Xilinx/Vivado/2022.2/settings64.sh: No such file or directory
    kasli_soc-standalone-gateware> Traceback (most recent call last):
    kasli_soc-standalone-gateware> File "/nix/store/a2iy41gccss952qhh8vnaivxjla29alq-gateware/kasli_soc.py", line 672, in <module>
    kasli_soc-standalone-gateware> main()
    kasli_soc-standalone-gateware> File "/nix/store/a2iy41gccss952qhh8vnaivxjla29alq-gateware/kasli_soc.py", line 668, in main
    kasli_soc-standalone-gateware> soc.build(build_dir=args.g)
    kasli_soc-standalone-gateware> File "/nix/store/vbv516vz6qi4m4wgavbdb1m1qwq7qnc4-python3-3.11.9-env/lib/python3.11/site-packages/migen_axi/integration/soc_core.py", line 169, in build
    kasli_soc-standalone-gateware> self.platform.build(self, *args, **kwargs)
    kasli_soc-standalone-gateware> File "/nix/store/vbv516vz6qi4m4wgavbdb1m1qwq7qnc4-python3-3.11.9-env/lib/python3.11/site-packages/migen/build/xilinx/platform.py", line 59, in build
    kasli_soc-standalone-gateware> return self.toolchain.build(self, *args, **kwargs)
    kasli_soc-standalone-gateware> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    kasli_soc-standalone-gateware> File "/nix/store/vbv516vz6qi4m4wgavbdb1m1qwq7qnc4-python3-3.11.9-env/lib/python3.11/site-packages/migen/build/xilinx/vivado.py", line 224, in build
    kasli_soc-standalone-gateware> _run_vivado(build_name)
    kasli_soc-standalone-gateware> File "/nix/store/vbv516vz6qi4m4wgavbdb1m1qwq7qnc4-python3-3.11.9-env/lib/python3.11/site-packages/migen/build/xilinx/vivado.py", line 69, in _run_vivado
    kasli_soc-standalone-gateware> raise OSError("Subprocess failed")
    kasli_soc-standalone-gateware> OSError: Subprocess failed

    I checked that the file settings64.sh exists. I also looked int /etc/profile and it only has 27 lines of code.

    My artiq-zynq package is NOT in /opt, but this should not be the problem.

    Any idea?

    I forgot to say that I am using Ubuntu 22.04.4 LTS

    Step 5 solved the problem. Thank you very much!

    2 months later

    @esavkin You could also set up an apparmor profile for Nix and possibly merge it upstream. But, of course, that takes more work.

    2 months later

    Hi I have a similar problem to lf_10 in which I have attempted to follow the same method in order to alleviate my problem.
    The following was entered:

    rabi@artiq ~> sudo nix build --print-build-logs --impure --expr 'let fl = builtins.getFlake "/home/rabi/artiq-zynq"; in (fl.makeArtiqZynqPackage {target="kasli_soc"; variant="standalone"; json=/home/rabi/auckland.json;}).kasli_soc-standalone-sd'

    This resulted in the following error:

    Grabber (EEM0) starting at RTIO channel 0x000000
    DIO (EEM2) starting at RTIO channel 0x000002
    Urukul (EEM3) starting at RTIO channel 0x00000a
    Sampler (EEM5) starting at RTIO channel 0x000010
    Fastino (EEM7) starting at RTIO channel 0x000013
    USER LED at RTIO channel 0x000014
    USER LED at RTIO channel 0x000015
    /etc/profile: line 36: /home/rabi/Xilinx/Vivado/2022.2/settings64.sh: No such file or directory
    Traceback (most recent call last):
      File "/nix/store/mwb3anly2pnvqwcsdzrzi3bmc0czb4gk-gateware/kasli_soc.py", line 672, in <module>
        main()
      File "/nix/store/mwb3anly2pnvqwcsdzrzi3bmc0czb4gk-gateware/kasli_soc.py", line 668, in main
        soc.build(build_dir=args.g)
      File "/nix/store/r5486bqn9pvhs2hqglqrxbiv1dlmgj83-python3-3.12.7-env/lib/python3.12/site-packages/migen_axi/integration/soc_core.py", line 169, in build
        self.platform.build(self, *args, **kwargs)
      File "/nix/store/r5486bqn9pvhs2hqglqrxbiv1dlmgj83-python3-3.12.7-env/lib/python3.12/site-packages/migen/build/xilinx/platform.py", line 59, in build
        return self.toolchain.build(self, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/nix/store/r5486bqn9pvhs2hqglqrxbiv1dlmgj83-python3-3.12.7-env/lib/python3.12/site-packages/migen/build/xilinx/vivado.py", line 224, in build
        _run_vivado(build_name)
      File "/nix/store/r5486bqn9pvhs2hqglqrxbiv1dlmgj83-python3-3.12.7-env/lib/python3.12/site-packages/migen/build/xilinx/vivado.py", line 69, in _run_vivado
        raise OSError("Subprocess failed")
    OSError: Subprocess failed

    Prior to reading through this thread I originally was struggling to get past having the vivado directory being from /opt/
    after following the instructions from architeuthis and fsagbuya such as cloning both artiq and artiq-zynq and proceeding to change the source and inputs.artiq.url, as well as including my vivado location to my sandbox-paths.

    I have now progressed to having

    USER LED at RTIO channel 0x000015
    /etc/profile: line 36: /home/rabi/Xilinx/Vivado/2022.2/settings64.sh: No such file or directory

    instead of:

    USER LED at RTIO channel 0x000015
    /etc/profile: line 36: /opt/Xilinx/Vivado/2022.2/settings64.sh: No such file or directory

    the directory /home/rabi/Xilinx/Vivado/2022.2/settings64.sh, does indeed exist, as well as having the following permissions

    rabi@artiq ~> ls  -l /home/rabi/Xilinx/Vivado/2022.2/settings64.sh
    -rwxr-xr-x 1 rabi users 508 Jan  8 22:50 /home/rabi/Xilinx/Vivado/2022.2/settings64.sh

    I am very new to linux, nixos, and artiq, so there is a high chance I have missed something simple. However I am able to run vivado outside of the context of this nix build command.

    If anyone could help out, I'd greatly appreciate it 🙂

    Happy New Year!

    Hi @hoogeroo , you will need to add the specified directory to the sandbox in flake in extra-sandbox-paths = "/opt"; and in trusted settings file.

      esavkin

      Thanks for the quick response yesterday

      I believe I have changed my path in the flake, and the sandbox. I installed my vivado in /home/rabi/Xilinx/

      artiq flake:

      vivado = pkgs.buildFHSEnv {
        name = "vivado";
        targetPkgs = vivadoDeps;
        profile = "set -e; source /home/rabi/Xilinx/Vivado/2022.2/settings64.sh";
        runScript = "vivado";
      };

      extra-sandbox-paths = "/home/rabi/Xilinx";
      };

      trusted settings; in .local/share/nix:

      "extra-sandbox-paths":{"/home/rabi/Xilinx":true},

      Just for some extra errors,

      when I try to source /home/rabi/Xilinx/Vivado/2022.2/settings64.sh inside fish I get:

      rabi@artiq ~ [1]> source /home/rabi/Xilinx/Vivado/2022.2/settings64.sh
      ~/Xilinx/DocNav/.settings64-DocNav.sh (line 5): Missing end to balance this if statement
      if [ -n "${PATH}" ]; then
      ^^
      from sourcing file ~/Xilinx/DocNav/.settings64-DocNav.sh
              called on line 5 of file ~/Xilinx/Vivado/2022.2/settings64.sh
      from sourcing file ~/Xilinx/Vivado/2022.2/settings64.sh
      source: Error while reading file '/home/rabi/Xilinx/DocNav/.settings64-DocNav.sh'
      ~/Xilinx/Vivado/2022.2/.settings64-Vivado.sh (line 6): Missing end to balance this if statement
      if [ -n "${PATH}" ]; then
      ^^
      from sourcing file ~/Xilinx/Vivado/2022.2/.settings64-Vivado.sh
              called on line 6 of file ~/Xilinx/Vivado/2022.2/settings64.sh
      from sourcing file ~/Xilinx/Vivado/2022.2/settings64.sh
      source: Error while reading file '/home/rabi/Xilinx/Vivado/2022.2/.settings64-Vivado.sh'
      ~/Xilinx/Vitis/2022.2/.settings64-Vitis.sh (line 6): Missing end to balance this if statement
      if [ -n "${PATH}" ]; then
      ^^
      from sourcing file ~/Xilinx/Vitis/2022.2/.settings64-Vitis.sh
              called on line 7 of file ~/Xilinx/Vivado/2022.2/settings64.sh
      from sourcing file ~/Xilinx/Vivado/2022.2/settings64.sh
      source: Error while reading file '/home/rabi/Xilinx/Vitis/2022.2/.settings64-Vitis.sh'
      ~/Xilinx/Model_Composer/2022.2/.settings64-Model_Composer.sh (line 5): Missing end to balance this if statement
      if [ -n "${PATH}" ]; then
      ^^
      from sourcing file ~/Xilinx/Model_Composer/2022.2/.settings64-Model_Composer.sh
              called on line 8 of file ~/Xilinx/Vivado/2022.2/settings64.sh
      from sourcing file ~/Xilinx/Vivado/2022.2/settings64.sh
      source: Error while reading file '/home/rabi/Xilinx/Model_Composer/2022.2/.settings64-Model_Composer.sh'
      ~/Xilinx/Vitis_HLS/2022.2/.settings64-Vitis_HLS.sh (line 6): Missing end to balance this if statement
      if [ -n "${PATH}" ]; then
      ^^
      from sourcing file ~/Xilinx/Vitis_HLS/2022.2/.settings64-Vitis_HLS.sh
              called on line 9 of file ~/Xilinx/Vivado/2022.2/settings64.sh
      from sourcing file ~/Xilinx/Vivado/2022.2/settings64.sh
      source: Error while reading file '/home/rabi/Xilinx/Vitis_HLS/2022.2/.settings64-Vitis_HLS.sh'

      When I source it in bash i get:

      [rabi@artiq:~/artiq]$ source /home/rabi/Xilinx/Vivado/2022.2/settings64.sh
      
      [rabi@artiq:~/artiq]$ echo $PATH
      /home/rabi/Xilinx/Vitis_HLS/2022.2/bin:/home/rabi/Xilinx/Model_Composer/2022.2/bin:/home/rabi/Xilinx/Vitis/2022.2/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/microblaze/lin/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/arm/lin/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/microblaze/linux_toolchain/lin64_le/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch32/lin/gcc-arm-none-eabi/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch64/lin/aarch64-linux/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch64/lin/aarch64-none/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/armr5/lin/gcc-arm-none-eabi/bin:/home/rabi/Xilinx/Vitis/2022.2/tps/lnx64/cmake-3.3.2/bin:/home/rabi/Xilinx/Vitis/2022.2/aietools/bin:/home/rabi/Xilinx/Vivado/2022.2/bin:/home/rabi/Xilinx/DocNav:/home/rabi/Xilinx/Vitis_HLS/2022.2/bin:/home/rabi/Xilinx/Model_Composer/2022.2/bin:/home/rabi/Xilinx/Vitis/2022.2/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/microblaze/lin/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/arm/lin/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/microblaze/linux_toolchain/lin64_le/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch32/lin/gcc-arm-none-eabi/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch64/lin/aarch64-linux/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch64/lin/aarch64-none/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/armr5/lin/gcc-arm-none-eabi/bin:/home/rabi/Xilinx/Vitis/2022.2/tps/lnx64/cmake-3.3.2/bin:/home/rabi/Xilinx/Vitis/2022.2/aietools/bin:/home/rabi/Xilinx/Vivado/2022.2/bin:/home/rabi/Xilinx/DocNav:/home/rabi/Xilinx/Vitis_HLS/2022.2/bin:/home/rabi/Xilinx/Model_Composer/2022.2/bin:/home/rabi/Xilinx/Vitis/2022.2/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/microblaze/lin/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/arm/lin/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/microblaze/linux_toolchain/lin64_le/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch32/lin/gcc-arm-none-eabi/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch64/lin/aarch64-linux/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch64/lin/aarch64-none/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/armr5/lin/gcc-arm-none-eabi/bin:/home/rabi/Xilinx/Vitis/2022.2/tps/lnx64/cmake-3.3.2/bin:/home/rabi/Xilinx/Vitis/2022.2/aietools/bin:/home/rabi/Xilinx/Vivado/2022.2/bin:/home/rabi/Xilinx/DocNav:/home/rabi/Xilinx/Vitis_HLS/2022.2/bin:/home/rabi/Xilinx/Model_Composer/2022.2/bin:/home/rabi/Xilinx/Vitis/2022.2/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/microblaze/lin/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/arm/lin/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/microblaze/linux_toolchain/lin64_le/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch32/lin/gcc-arm-none-eabi/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch64/lin/aarch64-linux/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/aarch64/lin/aarch64-none/bin:/home/rabi/Xilinx/Vitis/2022.2/gnu/armr5/lin/gcc-arm-none-eabi/bin:/home/rabi/Xilinx/Vitis/2022.2/tps/lnx64/cmake-3.3.2/bin:/home/rabi/Xilinx/Vitis/2022.2/aietools/bin:/home/rabi/Xilinx/Vivado/2022.2/bin:/home/rabi/Xilinx/DocNav:/run/wrappers/bin:/home/rabi/.nix-profile/bin:/nix/profile/bin:/home/rabi/.local/state/nix/profile/bin:/etc/profiles/per-user/rabi/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin

      I do now have:
      user/rabi/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin: No such file or directory

      which I didn't get last time I ran the cmd, although I haven't changed anything since then

      but still run into the same issue as before when I attempt the build command.

      Grabber (EEM0) starting at RTIO channel 0x000000
      DIO (EEM2) starting at RTIO channel 0x000002
      Urukul (EEM3) starting at RTIO channel 0x00000a
      Sampler (EEM5) starting at RTIO channel 0x000010
      Fastino (EEM7) starting at RTIO channel 0x000013
      USER LED at RTIO channel 0x000014
      USER LED at RTIO channel 0x000015
      /etc/profile: line 36: /home/rabi/Xilinx/Vivado/2022.2/settings64.sh: No such file or directory
      Traceback (most recent call last):
        File "/nix/store/mwb3anly2pnvqwcsdzrzi3bmc0czb4gk-gateware/kasli_soc.py", line 672, in <module>
          main()
        File "/nix/store/mwb3anly2pnvqwcsdzrzi3bmc0czb4gk-gateware/kasli_soc.py", line 668, in main
          soc.build(build_dir=args.g)
        File "/nix/store/r5486bqn9pvhs2hqglqrxbiv1dlmgj83-python3-3.12.7-env/lib/python3.12/site-packages/migen_axi/integration/soc_core.py", line 169, in build
          self.platform.build(self, *args, **kwargs)
        File "/nix/store/r5486bqn9pvhs2hqglqrxbiv1dlmgj83-python3-3.12.7-env/lib/python3.12/site-packages/migen/build/xilinx/platform.py", line 59, in build
          return self.toolchain.build(self, *args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/nix/store/r5486bqn9pvhs2hqglqrxbiv1dlmgj83-python3-3.12.7-env/lib/python3.12/site-packages/migen/build/xilinx/vivado.py", line 224, in build
          _run_vivado(build_name)
        File "/nix/store/r5486bqn9pvhs2hqglqrxbiv1dlmgj83-python3-3.12.7-env/lib/python3.12/site-packages/migen/build/xilinx/vivado.py", line 69, in _run_vivado
          raise OSError("Subprocess failed")
      OSError: Subprocess failed

      Is there a possibility I'm attempting to build in the wrong environment or directory?