How do I specify a path to an executable for a systemd unit file on nix?
I'm trying to write a systemd unit file.
How do I specify the path to an executable? How can I determine what to use?
In this specific case I'm trying to use mkdir.
ExecStartPre = "/bin/mkdir -p %h/.config/example/pending/";
This results in a error when starting the unit file though:
Jan 16 08:46:11 nixos systemd[19577]: example.service: Failed at step EXEC spawning /bin/mkdir: No such file or directory
I suppose I could just use which to find the path to mkdir - but I'm seeing a ${pkgs.nameOfPackage} in other's nix's config - so possibly I should be using this instead?
which mkdir
/run/current-system/sw/bin/mkdir
systemd environment-variables nixos mkdir nix
add a comment |
I'm trying to write a systemd unit file.
How do I specify the path to an executable? How can I determine what to use?
In this specific case I'm trying to use mkdir.
ExecStartPre = "/bin/mkdir -p %h/.config/example/pending/";
This results in a error when starting the unit file though:
Jan 16 08:46:11 nixos systemd[19577]: example.service: Failed at step EXEC spawning /bin/mkdir: No such file or directory
I suppose I could just use which to find the path to mkdir - but I'm seeing a ${pkgs.nameOfPackage} in other's nix's config - so possibly I should be using this instead?
which mkdir
/run/current-system/sw/bin/mkdir
systemd environment-variables nixos mkdir nix
add a comment |
I'm trying to write a systemd unit file.
How do I specify the path to an executable? How can I determine what to use?
In this specific case I'm trying to use mkdir.
ExecStartPre = "/bin/mkdir -p %h/.config/example/pending/";
This results in a error when starting the unit file though:
Jan 16 08:46:11 nixos systemd[19577]: example.service: Failed at step EXEC spawning /bin/mkdir: No such file or directory
I suppose I could just use which to find the path to mkdir - but I'm seeing a ${pkgs.nameOfPackage} in other's nix's config - so possibly I should be using this instead?
which mkdir
/run/current-system/sw/bin/mkdir
systemd environment-variables nixos mkdir nix
I'm trying to write a systemd unit file.
How do I specify the path to an executable? How can I determine what to use?
In this specific case I'm trying to use mkdir.
ExecStartPre = "/bin/mkdir -p %h/.config/example/pending/";
This results in a error when starting the unit file though:
Jan 16 08:46:11 nixos systemd[19577]: example.service: Failed at step EXEC spawning /bin/mkdir: No such file or directory
I suppose I could just use which to find the path to mkdir - but I'm seeing a ${pkgs.nameOfPackage} in other's nix's config - so possibly I should be using this instead?
which mkdir
/run/current-system/sw/bin/mkdir
systemd environment-variables nixos mkdir nix
systemd environment-variables nixos mkdir nix
edited yesterday
GAD3R
25.9k1751107
25.9k1751107
asked yesterday
Chris StryczynskiChris Stryczynski
559417
559417
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Generally speaking, ${pkgs.nameOfPackage} is the preferred syntax.
For your specific examplem mkdir is part of the coreutils package; which (pun intended) you can determine with the command readlink $(which mkdir). So your line should read:
ExecStartPre=${pkgs.coreutils}/bin/mkdir BLAH BLAH BLAH
While coreutils is always installed AFIK, a nice benefit of the ${pkgs.nameOfPackage} syntax is that you don't need to install the package nameOfPackage; Nix will pull it in for you.
add a comment |
First you don't need those spaces and double quotes.
ExecStartPre=/run/current-system/sw/bin/mkdir -p %h/.config/example/pending
Secondly, have you tried the command on your system as it is written ?
In your shell:
mkdir -p ~/.config/example/pending
Lastly, %h refers to the user's home. But maybe your system is targeting to another place, since the mkdir command isn't in the right place. echo ~ to see your home directory.
New contributor
jayooin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Welcome ,mkdiris under/run/current-system/sw/bin/aswhichcommand say.
– GAD3R
yesterday
1
Yes, but there could be a symlink, in which case the /bin/mkdir could work.
– jayooin
yesterday
1
@GAD3Rmkdiris found first in the OP's $PATH in /run/current-system/sw/bin/ but that doesn't tell us much about where systemd should look.
– icarus
yesterday
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494762%2fhow-do-i-specify-a-path-to-an-executable-for-a-systemd-unit-file-on-nix%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Generally speaking, ${pkgs.nameOfPackage} is the preferred syntax.
For your specific examplem mkdir is part of the coreutils package; which (pun intended) you can determine with the command readlink $(which mkdir). So your line should read:
ExecStartPre=${pkgs.coreutils}/bin/mkdir BLAH BLAH BLAH
While coreutils is always installed AFIK, a nice benefit of the ${pkgs.nameOfPackage} syntax is that you don't need to install the package nameOfPackage; Nix will pull it in for you.
add a comment |
Generally speaking, ${pkgs.nameOfPackage} is the preferred syntax.
For your specific examplem mkdir is part of the coreutils package; which (pun intended) you can determine with the command readlink $(which mkdir). So your line should read:
ExecStartPre=${pkgs.coreutils}/bin/mkdir BLAH BLAH BLAH
While coreutils is always installed AFIK, a nice benefit of the ${pkgs.nameOfPackage} syntax is that you don't need to install the package nameOfPackage; Nix will pull it in for you.
add a comment |
Generally speaking, ${pkgs.nameOfPackage} is the preferred syntax.
For your specific examplem mkdir is part of the coreutils package; which (pun intended) you can determine with the command readlink $(which mkdir). So your line should read:
ExecStartPre=${pkgs.coreutils}/bin/mkdir BLAH BLAH BLAH
While coreutils is always installed AFIK, a nice benefit of the ${pkgs.nameOfPackage} syntax is that you don't need to install the package nameOfPackage; Nix will pull it in for you.
Generally speaking, ${pkgs.nameOfPackage} is the preferred syntax.
For your specific examplem mkdir is part of the coreutils package; which (pun intended) you can determine with the command readlink $(which mkdir). So your line should read:
ExecStartPre=${pkgs.coreutils}/bin/mkdir BLAH BLAH BLAH
While coreutils is always installed AFIK, a nice benefit of the ${pkgs.nameOfPackage} syntax is that you don't need to install the package nameOfPackage; Nix will pull it in for you.
answered 14 hours ago
Emmanuel RosaEmmanuel Rosa
3,0801612
3,0801612
add a comment |
add a comment |
First you don't need those spaces and double quotes.
ExecStartPre=/run/current-system/sw/bin/mkdir -p %h/.config/example/pending
Secondly, have you tried the command on your system as it is written ?
In your shell:
mkdir -p ~/.config/example/pending
Lastly, %h refers to the user's home. But maybe your system is targeting to another place, since the mkdir command isn't in the right place. echo ~ to see your home directory.
New contributor
jayooin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Welcome ,mkdiris under/run/current-system/sw/bin/aswhichcommand say.
– GAD3R
yesterday
1
Yes, but there could be a symlink, in which case the /bin/mkdir could work.
– jayooin
yesterday
1
@GAD3Rmkdiris found first in the OP's $PATH in /run/current-system/sw/bin/ but that doesn't tell us much about where systemd should look.
– icarus
yesterday
add a comment |
First you don't need those spaces and double quotes.
ExecStartPre=/run/current-system/sw/bin/mkdir -p %h/.config/example/pending
Secondly, have you tried the command on your system as it is written ?
In your shell:
mkdir -p ~/.config/example/pending
Lastly, %h refers to the user's home. But maybe your system is targeting to another place, since the mkdir command isn't in the right place. echo ~ to see your home directory.
New contributor
jayooin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Welcome ,mkdiris under/run/current-system/sw/bin/aswhichcommand say.
– GAD3R
yesterday
1
Yes, but there could be a symlink, in which case the /bin/mkdir could work.
– jayooin
yesterday
1
@GAD3Rmkdiris found first in the OP's $PATH in /run/current-system/sw/bin/ but that doesn't tell us much about where systemd should look.
– icarus
yesterday
add a comment |
First you don't need those spaces and double quotes.
ExecStartPre=/run/current-system/sw/bin/mkdir -p %h/.config/example/pending
Secondly, have you tried the command on your system as it is written ?
In your shell:
mkdir -p ~/.config/example/pending
Lastly, %h refers to the user's home. But maybe your system is targeting to another place, since the mkdir command isn't in the right place. echo ~ to see your home directory.
New contributor
jayooin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
First you don't need those spaces and double quotes.
ExecStartPre=/run/current-system/sw/bin/mkdir -p %h/.config/example/pending
Secondly, have you tried the command on your system as it is written ?
In your shell:
mkdir -p ~/.config/example/pending
Lastly, %h refers to the user's home. But maybe your system is targeting to another place, since the mkdir command isn't in the right place. echo ~ to see your home directory.
New contributor
jayooin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited yesterday
New contributor
jayooin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered yesterday
jayooinjayooin
654
654
New contributor
jayooin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
jayooin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
jayooin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Welcome ,mkdiris under/run/current-system/sw/bin/aswhichcommand say.
– GAD3R
yesterday
1
Yes, but there could be a symlink, in which case the /bin/mkdir could work.
– jayooin
yesterday
1
@GAD3Rmkdiris found first in the OP's $PATH in /run/current-system/sw/bin/ but that doesn't tell us much about where systemd should look.
– icarus
yesterday
add a comment |
Welcome ,mkdiris under/run/current-system/sw/bin/aswhichcommand say.
– GAD3R
yesterday
1
Yes, but there could be a symlink, in which case the /bin/mkdir could work.
– jayooin
yesterday
1
@GAD3Rmkdiris found first in the OP's $PATH in /run/current-system/sw/bin/ but that doesn't tell us much about where systemd should look.
– icarus
yesterday
Welcome ,
mkdir is under /run/current-system/sw/bin/ as which command say.– GAD3R
yesterday
Welcome ,
mkdir is under /run/current-system/sw/bin/ as which command say.– GAD3R
yesterday
1
1
Yes, but there could be a symlink, in which case the /bin/mkdir could work.
– jayooin
yesterday
Yes, but there could be a symlink, in which case the /bin/mkdir could work.
– jayooin
yesterday
1
1
@GAD3R
mkdir is found first in the OP's $PATH in /run/current-system/sw/bin/ but that doesn't tell us much about where systemd should look.– icarus
yesterday
@GAD3R
mkdir is found first in the OP's $PATH in /run/current-system/sw/bin/ but that doesn't tell us much about where systemd should look.– icarus
yesterday
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494762%2fhow-do-i-specify-a-path-to-an-executable-for-a-systemd-unit-file-on-nix%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown